1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00
only disable `--rm` at end of command line parsing,
so that `-c` only disables `--rm` if it's effectively selected,
and not if it's overriden by a later `-o FILE` command.
This commit is contained in:
Yann Collet
2024-03-11 11:38:55 -07:00
parent 372fddf4e6
commit c610a01d7d
2 changed files with 17 additions and 7 deletions

View File

@ -225,15 +225,17 @@ the last one takes effect.
This parameter defines a loose target: compressed blocks will target this size "on average", but individual blocks can still be larger or smaller. This parameter defines a loose target: compressed blocks will target this size "on average", but individual blocks can still be larger or smaller.
Enabling this feature can decrease compression speed by up to ~10% at level 1. Enabling this feature can decrease compression speed by up to ~10% at level 1.
Higher levels will see smaller relative speed regression, becoming invisible at higher settings. Higher levels will see smaller relative speed regression, becoming invisible at higher settings.
* `-o FILE`:
save result into `FILE`.
* `-f`, `--force`: * `-f`, `--force`:
disable input and output checks. Allows overwriting existing files, input disable input and output checks. Allows overwriting existing files, input
from console, output to stdout, operating on links, block devices, etc. from console, output to stdout, operating on links, block devices, etc.
During decompression and when the output destination is stdout, pass-through During decompression and when the output destination is stdout, pass-through
unrecognized formats as-is. unrecognized formats as-is.
* `-c`, `--stdout`: * `-c`, `--stdout`:
write to standard output (even if it is the console); keep original files unchanged. write to standard output (even if it is the console); keep original files (disable `--rm`).
* `-o FILE`:
save result into `FILE`.
This command is in conflict with `-c`.
If both are present on the command line, the last expressed one wins.
* `--[no-]sparse`: * `--[no-]sparse`:
enable / disable sparse FS support, enable / disable sparse FS support,
to make files with many zeroes smaller on disk. to make files with many zeroes smaller on disk.

View File

@ -1176,7 +1176,10 @@ int main(int argCount, const char* argv[])
operation=zom_decompress; argument++; break; operation=zom_decompress; argument++; break;
/* Force stdout, even if stdout==console */ /* Force stdout, even if stdout==console */
case 'c': forceStdout=1; outFileName=stdoutmark; removeSrcFile=0; argument++; break; case 'c': forceStdout=1; outFileName=stdoutmark; argument++; break;
/* destination file name */
case 'o': argument++; NEXT_FIELD(outFileName); break;
/* do not store filename - gzip compatibility - nothing to do */ /* do not store filename - gzip compatibility - nothing to do */
case 'n': argument++; break; case 'n': argument++; break;
@ -1202,9 +1205,6 @@ int main(int argCount, const char* argv[])
/* test compressed file */ /* test compressed file */
case 't': operation=zom_test; argument++; break; case 't': operation=zom_test; argument++; break;
/* destination file name */
case 'o': argument++; NEXT_FIELD(outFileName); break;
/* limit memory */ /* limit memory */
case 'M': case 'M':
argument++; argument++;
@ -1367,6 +1367,14 @@ int main(int argCount, const char* argv[])
#endif #endif
} }
/* disable --rm when writing to stdout */
if (!strcmp(outFileName, stdoutmark)) {
if (removeSrcFile) {
DISPLAYLEVEL(2, "warning: source not removed when writing to stdout \n");
removeSrcFile = 0;
}
}
/* Check if benchmark is selected */ /* Check if benchmark is selected */
if (operation==zom_bench) { if (operation==zom_bench) {
#ifndef ZSTD_NOBENCH #ifndef ZSTD_NOBENCH