Add new stdoutOutput field
parent
f7d4943788
commit
1ebe360d0f
|
@ -331,6 +331,7 @@ struct FIO_ctx_s {
|
||||||
/* file i/o info */
|
/* file i/o info */
|
||||||
int nbFilesTotal;
|
int nbFilesTotal;
|
||||||
int hasStdinInput;
|
int hasStdinInput;
|
||||||
|
int hasStdoutOutput;
|
||||||
|
|
||||||
/* file i/o state */
|
/* file i/o state */
|
||||||
int currFileIdx;
|
int currFileIdx;
|
||||||
|
@ -388,6 +389,7 @@ FIO_ctx_t* FIO_createContext(void)
|
||||||
|
|
||||||
ret->currFileIdx = 0;
|
ret->currFileIdx = 0;
|
||||||
ret->hasStdinInput = 0;
|
ret->hasStdinInput = 0;
|
||||||
|
ret->hasStdoutOutput = 0;
|
||||||
ret->nbFilesTotal = 1;
|
ret->nbFilesTotal = 1;
|
||||||
ret->nbFilesProcessed = 0;
|
ret->nbFilesProcessed = 0;
|
||||||
ret->totalBytesInput = 0;
|
ret->totalBytesInput = 0;
|
||||||
|
@ -536,6 +538,10 @@ void FIO_setContentSize(FIO_prefs_t* const prefs, int value)
|
||||||
|
|
||||||
/* FIO_ctx_t functions */
|
/* FIO_ctx_t functions */
|
||||||
|
|
||||||
|
void FIO_setHasStdoutOutput(FIO_ctx_t* const fCtx, int value) {
|
||||||
|
fCtx->hasStdoutOutput = value;
|
||||||
|
}
|
||||||
|
|
||||||
void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value)
|
void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value)
|
||||||
{
|
{
|
||||||
fCtx->nbFilesTotal = value;
|
fCtx->nbFilesTotal = value;
|
||||||
|
@ -841,6 +847,7 @@ static void FIO_adjustMemLimitForPatchFromMode(FIO_prefs_t* const prefs,
|
||||||
* If -q is specified with --rm, zstd will abort pre-emptively
|
* 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 neither flag is specified, zstd will prompt the user for confirmation to proceed.
|
||||||
* If --rm is not specified, then zstd will print a warning to the user (which can be silenced with -q).
|
* If --rm is not specified, then zstd will print a warning to the user (which can be silenced with -q).
|
||||||
|
* However, if the output is stdout, we will always abort rather than displaying the warning prompt.
|
||||||
*/
|
*/
|
||||||
static int FIO_removeMultiFilesWarning(FIO_ctx_t* const fCtx, const FIO_prefs_t* const prefs, const char* outFileName, int displayLevelCutoff)
|
static int FIO_removeMultiFilesWarning(FIO_ctx_t* const fCtx, const FIO_prefs_t* const prefs, const char* outFileName, int displayLevelCutoff)
|
||||||
{
|
{
|
||||||
|
@ -859,7 +866,12 @@ 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", fCtx->hasStdinInput);
|
if (fCtx->hasStdoutOutput) {
|
||||||
|
DISPLAYLEVEL(1, "\nAborting. Use -f if you really want to delete the files and output to stdout");
|
||||||
|
error = 1;
|
||||||
|
} else {
|
||||||
|
error = g_display_prefs.displayLevel > displayLevelCutoff && UTIL_requireUserConfirmation("This is a destructive operation. Proceed? (y/n): ", "Aborting...", "yY", fCtx->hasStdinInput);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DISPLAY("\n");
|
DISPLAY("\n");
|
||||||
|
@ -1532,20 +1544,20 @@ FIO_compressFilename_internal(FIO_ctx_t* const fCtx,
|
||||||
fCtx->totalBytesInput += (size_t)readsize;
|
fCtx->totalBytesInput += (size_t)readsize;
|
||||||
fCtx->totalBytesOutput += (size_t)compressedfilesize;
|
fCtx->totalBytesOutput += (size_t)compressedfilesize;
|
||||||
DISPLAYLEVEL(2, "\r%79s\r", "");
|
DISPLAYLEVEL(2, "\r%79s\r", "");
|
||||||
if (g_display_prefs.displayLevel >= 2) {
|
if (g_display_prefs.displayLevel >= 2 &&
|
||||||
if (g_display_prefs.displayLevel >= 3 || fCtx->nbFilesTotal <= 1) {
|
!fCtx->hasStdoutOutput &&
|
||||||
if (readsize == 0) {
|
(g_display_prefs.displayLevel >= 3 || fCtx->nbFilesTotal <= 1)) {
|
||||||
DISPLAYLEVEL(2,"%-20s : (%6llu => %6llu bytes, %s) \n",
|
if (readsize == 0) {
|
||||||
srcFileName,
|
DISPLAYLEVEL(2,"%-20s : (%6llu => %6llu bytes, %s) \n",
|
||||||
(unsigned long long)readsize, (unsigned long long) compressedfilesize,
|
srcFileName,
|
||||||
dstFileName);
|
(unsigned long long)readsize, (unsigned long long) compressedfilesize,
|
||||||
} else {
|
dstFileName);
|
||||||
DISPLAYLEVEL(2,"%-20s :%6.2f%% (%6llu => %6llu bytes, %s) \n",
|
} else {
|
||||||
srcFileName,
|
DISPLAYLEVEL(2,"%-20s :%6.2f%% (%6llu => %6llu bytes, %s) \n",
|
||||||
(double)compressedfilesize / readsize * 100,
|
srcFileName,
|
||||||
(unsigned long long)readsize, (unsigned long long) compressedfilesize,
|
(double)compressedfilesize / readsize * 100,
|
||||||
dstFileName);
|
(unsigned long long)readsize, (unsigned long long) compressedfilesize,
|
||||||
}
|
dstFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue