From: senhuang42 Date: Thu, 24 Sep 2020 19:55:30 +0000 (-0400) Subject: Add FIO_determineHasStdinInput() function and member to fCtx X-Git-Tag: v1.4.7~68^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=432186cbea108291dff4785cb2bcc098e03aafb7;p=thirdparty%2Fzstd.git Add FIO_determineHasStdinInput() function and member to fCtx --- diff --git a/programs/fileio.c b/programs/fileio.c index b8700f5d4..aa28d05f2 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -330,6 +330,7 @@ struct FIO_ctx_s { /* file i/o info */ int nbFilesTotal; + int hasStdinInput; /* file i/o state */ int currFileIdx; @@ -386,6 +387,7 @@ FIO_ctx_t* FIO_createContext(void) if (!ret) EXM_THROW(21, "Allocation error : not enough memory"); ret->currFileIdx = 0; + ret->hasStdinInput = 0; ret->nbFilesTotal = 1; ret->nbFilesProcessed = 0; ret->totalBytesInput = 0; @@ -539,6 +541,16 @@ void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value) fCtx->nbFilesTotal = value; } +void FIO_determineHasStdinInput(FIO_ctx_t* const fCtx, const FileNamesTable* const filenames) { + int i = 0; + for ( ; i < filenames->tableSize; ++i) { + if (!strcmp(stdinmark, filenames->fileNames[i])) { + fCtx->hasStdinInput = 1; + return; + } + } +} + /*-************************************* * Functions ***************************************/ diff --git a/programs/fileio.h b/programs/fileio.h index bec651a15..866d679d9 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -106,6 +106,7 @@ void FIO_setContentSize(FIO_prefs_t* const prefs, int value); /* FIO_ctx_t functions */ void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value); +void FIO_determineHasStdinInput(FIO_ctx_t* const fCtx, const FileNamesTable* const filenames); /*-************************************* * Single File functions diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 5d1c09de6..3df91c10e 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -1286,6 +1286,7 @@ int main(int const argCount, const char* argv[]) /* IO Stream/File */ FIO_setNbFilesTotal(fCtx, (int)filenames->tableSize); + FIO_determineHasStdinInput(fCtx, filenames); FIO_setNotificationLevel(g_displayLevel); FIO_setPatchFromMode(prefs, patchFromDictFileName != NULL); if (memLimit == 0) {