From 7a7cd8861ae990660fea1d4703259edfa6ec1baf Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Tue, 25 Aug 2020 13:50:44 -0400 Subject: [PATCH] Add initial functionality to support -q --- programs/fileio.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 9eb35fa8f..f2978fe8b 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1672,14 +1672,23 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs, assert(outFileName != NULL || suffix != NULL); if (outFileName != NULL) { /* output into a single destination (stdout typically) */ if (nbFiles > 1 && !prefs->overwrite) { - if (!strcmp (outFileName, stdoutmark)) { - DISPLAY("zstd: WARNING: all input files will be processed and concatenated into stdout. "); + /* g_display_prefs.displayLevel <= 1 corresponds to -q flag */ + DISPLAY("%d\n", g_display_prefs.displayLevel); + if (g_display_prefs.displayLevel <= 1) { + if (prefs->removeSrcFile) { + DISPLAY("zstd: Aborting... not deleting files and processing into dst: %s", outFileName); + return 1; + } } else { - DISPLAY("zstd: WARNING: all input files will be processed and concatenated into a single output file: %s ", outFileName); + 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) + error = g_display_prefs.displayLevel > 1 && UTIL_requireUserConfirmationToProceed("Proceed? (y/n): ", "Aborting...", "yY"); + DISPLAY("\n"); } - if (prefs->removeSrcFile) - error = UTIL_requireUserConfirmationToProceed("Proceed? (y/n): ", "Aborting...", "yY"); - DISPLAY("\n"); } ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName); if (ress.dstFile == NULL) { /* could not open outFileName */