ckolivas / lrzip

Long Range Zip
http://lrzip.kolivas.org
GNU General Public License v2.0
619 stars 76 forks source link

Revert "BUGFIX: lrzip -d, -t should allow a file with or without an lrz extension and add if necessary" #159

Closed ckolivas closed 4 years ago

ckolivas commented 4 years ago

Reverts ckolivas/lrzip#157

Please correct ability to compress any filename.

pete4abw commented 4 years ago

This only affects decompressing or testing files. It does not affect compressing. See main.c if (infile && !(DECOMPRESS || TEST_ONLY)) {

and NOT Decompressing or Testing. Works as designed.

Compressing works as normal and is not changed by this. Compress

$ lrzip/lrzip lrzip.tar
Output filename is: lrzip.tar.lrz 
lrzip.tar - Compression Ratio: 4.543. Average Compression Speed:  5.333MB/s
Total time: 00:00:02.07

Test with Extension

$ lrzip/lrzip -t lrzip.tar.lrz
Decompressing...
100%      16.88 /     16.88 MB
Average DeCompression Speed: 16.000MB/s
[OK] - 17694720 bytes
Total time: 00:00:00.35

Test without Extension

$ lrzip/lrzip -t lrzip.tar
Decompressing...
100%      16.88 /     16.88 MB
Average DeCompression Speed: 16.000MB/s
[OK] - 17694720 bytes
Total time: 00:00:00.35

Decompress WITH Extension and Uncompressed file exists

$ lrzip/lrzip -d lrzip.tar.lrz
Output filename is: lrzip.tar
Failed to create lrzip.tar
File exists
Fatal error - exiting

Decompress without Extension AND Uncompressed file exists

$ lrzip/lrzip -d lrzip.tar
Output filename is: lrzip.tar
Failed to create lrzip.tar
File exists
Fatal error - exiting

$ rm lrzip.tar Decompress without Extension

$ lrzip/lrzip -d lrzip.tar
Output filename is: lrzip.tar
Decompressing...
100%      16.88 /     16.88 MB
Average DeCompression Speed: 16.000MB/s
Output filename is: lrzip.tar: [OK] - 17694720 bytes
Total time: 00:00:00.35

$ rm lrzip.tar Decompress WITH Extension

$ lrzip/lrzip -d lrzip.tar.lrz
Output filename is: lrzip.tar
Decompressing...
100%      16.88 /     16.88 MB
Average DeCompression Speed: 16.000MB/s
Output filename is: lrzip.tar: [OK] - 17694720 bytes                                
Total time: 00:00:00.35
ckolivas commented 4 years ago

This only affects decompressing or testing files. It does not affect compressing. See main.c if (infile && !(DECOMPRESS || TEST_ONLY)) {

!DECOMPRESS would mean compress, no?

pete4abw commented 4 years ago

NOT (DECOMPRESS or TEST_ONLY)

So yes, if there IS an infile AND we are NOT ( Decompressing OR Testing )

The code Stanza in lrzip.c does not work as designed. I believe that this broke with the addition of STDIN and STDOUT functionality.

        stat(control->infile, &fdin_stat);
        if (!S_ISREG(fdin_stat.st_mode) && (tmp = strrchr(control->infile, '.')) &&
            strcmp(tmp,control->suffix)) {
            /* make sure infile has an extension. If not, add it
              * because manipulations may be made to input filename, set local ptr
            */

No big deal though. No one has ever complained about this. Just wanted to restore designed functionality.