flanglet / kanzi-cpp

Fast lossless data compression in C++
Apache License 2.0
137 stars 3 forks source link

Empty file compression #8

Closed twekkel closed 2 years ago

twekkel commented 2 years ago

Again not a big issue, but if there is "nothing to do" the output file "test.knz" should probably not be created.

$ touch test $ ./kanzi -c -i test

Kanzi 2.0 (c) Frederic Langlet

1 file to compress

Input file test is empty ... nothing to do $ ./kanzi -d -i test.knz -o stdout Invalid stream type. Error code: 15

flanglet commented 2 years ago

Commit [23a503a]

tansy commented 11 months ago

I'm not sure about this. Every compressor can and does compress empty file/s without issue. Actually, lzfse had an issue with them and that's considered a bug. In case of automatic or scripted compression one does not care whether file is empty, they care about getting correct archive. When there is no archive produced then there must be a reason for it, and an error is probably assumed at first. But even if you don't consider it an error, then if you don't have an archive you don't have a file after decompression, which can be an issue as you did assume all files were compressed, regardless their size.