Add a warning whenever (de)compressing multiple files into one source, or into stdout

This commit is contained in:
senhuang42
2020-08-24 19:10:03 -04:00
parent 5d91206ebe
commit 1acf243540
2 changed files with 38 additions and 9 deletions
+23
View File
@@ -1677,6 +1677,29 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
/* init */
assert(outFileName != NULL || suffix != NULL);
if (outFileName != NULL) { /* output into a single destination (stdout typically) */
if (nbFiles > 1) {
if (!strcmp (outFileName, stdoutmark)) {
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into stdout. ");
} else {
DISPLAY("zstd: WARNING: all input files will be processed and concatenated into a single output file: %s ", outFileName);
}
if (prefs->removeSrcFile && !prefs->overwrite) {
DISPLAY("\nYou must specify -f as well in order to execute this command with --rm. Aborting...");
return 1;
}
DISPLAY("Proceed? (y/n): ");
{
int ch = getchar();
if ((ch != 'y') && (ch != 'Y')) {
DISPLAY("zstd: aborting...\n");
return 1;
}
/* flush the rest */
while ((ch!=EOF) && (ch!='\n'))
ch = getchar();
}
}
ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName);
if (ress.dstFile == NULL) { /* could not open outFileName */
error = 1;