From 01828b27e28988e77edaf1178253bbf7cb21b08e Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Thu, 27 Aug 2020 17:57:20 -0400 Subject: [PATCH] Improve documentation, update man --- programs/fileio.c | 17 ++++++++++++----- programs/zstd.1.md | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 3eaa0455a..03b282b88 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -791,13 +791,18 @@ static void FIO_adjustMemLimitForPatchFromMode(FIO_prefs_t* const prefs, /* FIO_removeMultiFilesWarning() : * Returns 1 if the console should abort, 0 if console should proceed. - * Based on displayLevelCutoff (typically == 1) and the global setting g_display_prefs.displayLevel, this - * function may print a warning message, a user prompt, both, or none. + * This function handles logic when processing multiple files with -o, displaying the appropriate warnings/prompts. + * + * If -f is specified, or there is just 1 file, zstd will always proceed as usual. + * If --rm is specified, there will be a prompt asking for user confirmation. + * If -f is specified with --rm, zstd will proceed as usual + * If -q is specified with --rm, zstd will abort pre-emptively + * If neither flag is specified, zstd will prompt the user for confirmation to proceed. + * If --rm is not specified, then zstd may print a warning to the user. */ static int FIO_removeMultiFilesWarning(const FIO_prefs_t* const prefs, int displayLevelCutoff, const char* outFileName) { - int error; - error = 0; + int error = 0; if (prefs->nbFiles > 1 && !prefs->overwrite) { if (g_display_prefs.displayLevel <= displayLevelCutoff) { if (prefs->removeSrcFile) { @@ -810,8 +815,10 @@ static int FIO_removeMultiFilesWarning(const FIO_prefs_t* const prefs, int displ } else { DISPLAYLEVEL(2, "zstd: WARNING: all input files will be processed and concatenated into a single output file: %s ", outFileName); } - if (prefs->removeSrcFile) + if (prefs->removeSrcFile) { + DISPLAYLEVEL(2, "\nThe concatenated output CANNOT regenerate the original directory tree. This is a destructive operation. ") error = g_display_prefs.displayLevel > displayLevelCutoff && UTIL_requireUserConfirmation("Proceed? (y/n): ", "Aborting...", "yY"); + } DISPLAY("\n"); } } diff --git a/programs/zstd.1.md b/programs/zstd.1.md index 5b90b2df0..e7fa9cd4e 100644 --- a/programs/zstd.1.md +++ b/programs/zstd.1.md @@ -213,7 +213,8 @@ the last one takes effect. and disabled when output is stdout. This setting overrides default and can force sparse mode over stdout. * `--rm`: - remove source file(s) after successful compression or decompression + remove source file(s) after successful compression or decompression. If used in combination with + -o, will trigger a confirmation prompt (which can be silenced with -f), as this is a destructive operation. * `-k`, `--keep`: keep source file(s) after successful compression or decompression. This is the default behavior.