Expand UTIL_requireUserConfirmation to include stdin input check
This commit is contained in:
parent
432186cbea
commit
93d63eaeb8
@ -662,7 +662,7 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
DISPLAY("zstd: %s already exists; ", dstFileName);
|
DISPLAY("zstd: %s already exists; ", dstFileName);
|
||||||
if (UTIL_requireUserConfirmation("overwrite (y/n) ? ", "Not overwritten \n", "yY"))
|
if (UTIL_requireUserConfirmation("overwrite (y/n) ? ", "Not overwritten \n", "yY", fCtx->hasStdinInput))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* need to unlink */
|
/* need to unlink */
|
||||||
@ -859,7 +859,7 @@ static int FIO_removeMultiFilesWarning(FIO_ctx_t* const fCtx, const FIO_prefs_t*
|
|||||||
}
|
}
|
||||||
DISPLAYLEVEL(2, "\nThe concatenated output CANNOT regenerate the original directory tree. ")
|
DISPLAYLEVEL(2, "\nThe concatenated output CANNOT regenerate the original directory tree. ")
|
||||||
if (prefs->removeSrcFile) {
|
if (prefs->removeSrcFile) {
|
||||||
error = g_display_prefs.displayLevel > displayLevelCutoff && UTIL_requireUserConfirmation("This is a destructive operation. Proceed? (y/n): ", "Aborting...", "yY");
|
error = g_display_prefs.displayLevel > displayLevelCutoff && UTIL_requireUserConfirmation("This is a destructive operation. Proceed? (y/n): ", "Aborting...", "yY", fCtx->hasStdinInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DISPLAY("\n");
|
DISPLAY("\n");
|
||||||
|
@ -88,9 +88,12 @@ UTIL_STATIC void* UTIL_realloc(void *ptr, size_t size)
|
|||||||
int g_utilDisplayLevel;
|
int g_utilDisplayLevel;
|
||||||
|
|
||||||
int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
|
int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
|
||||||
const char* acceptableLetters) {
|
const char* acceptableLetters, int hasStdinInput) {
|
||||||
int ch, result;
|
int ch, result;
|
||||||
|
|
||||||
|
if (hasStdinInput)
|
||||||
|
return 1;
|
||||||
|
|
||||||
UTIL_DISPLAY("%s", prompt);
|
UTIL_DISPLAY("%s", prompt);
|
||||||
ch = getchar();
|
ch = getchar();
|
||||||
result = 0;
|
result = 0;
|
||||||
|
@ -96,8 +96,9 @@ extern int g_utilDisplayLevel;
|
|||||||
/**
|
/**
|
||||||
* Displays a message prompt and returns success (0) if first character from stdin
|
* Displays a message prompt and returns success (0) if first character from stdin
|
||||||
* matches any from acceptableLetters. Otherwise, returns failure (1) and displays abortMsg.
|
* matches any from acceptableLetters. Otherwise, returns failure (1) and displays abortMsg.
|
||||||
|
* If any of the inputs are stdin itself, then automatically return failure (1).
|
||||||
*/
|
*/
|
||||||
int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const char* acceptableLetters);
|
int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const char* acceptableLetters, int hasStdinInput);
|
||||||
|
|
||||||
|
|
||||||
/*-****************************************
|
/*-****************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user