1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

Add FIO_determineHasStdinInput() function and member to fCtx

This commit is contained in:
senhuang42
2020-09-24 15:55:30 -04:00
parent 0e8ac6b995
commit 432186cbea
3 changed files with 14 additions and 0 deletions

View File

@ -330,6 +330,7 @@ struct FIO_ctx_s {
/* file i/o info */ /* file i/o info */
int nbFilesTotal; int nbFilesTotal;
int hasStdinInput;
/* file i/o state */ /* file i/o state */
int currFileIdx; int currFileIdx;
@ -386,6 +387,7 @@ FIO_ctx_t* FIO_createContext(void)
if (!ret) EXM_THROW(21, "Allocation error : not enough memory"); if (!ret) EXM_THROW(21, "Allocation error : not enough memory");
ret->currFileIdx = 0; ret->currFileIdx = 0;
ret->hasStdinInput = 0;
ret->nbFilesTotal = 1; ret->nbFilesTotal = 1;
ret->nbFilesProcessed = 0; ret->nbFilesProcessed = 0;
ret->totalBytesInput = 0; ret->totalBytesInput = 0;
@ -539,6 +541,16 @@ void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value)
fCtx->nbFilesTotal = 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 * Functions
***************************************/ ***************************************/

View File

@ -106,6 +106,7 @@ void FIO_setContentSize(FIO_prefs_t* const prefs, int value);
/* FIO_ctx_t functions */ /* FIO_ctx_t functions */
void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value); 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 * Single File functions

View File

@ -1286,6 +1286,7 @@ int main(int const argCount, const char* argv[])
/* IO Stream/File */ /* IO Stream/File */
FIO_setNbFilesTotal(fCtx, (int)filenames->tableSize); FIO_setNbFilesTotal(fCtx, (int)filenames->tableSize);
FIO_determineHasStdinInput(fCtx, filenames);
FIO_setNotificationLevel(g_displayLevel); FIO_setNotificationLevel(g_displayLevel);
FIO_setPatchFromMode(prefs, patchFromDictFileName != NULL); FIO_setPatchFromMode(prefs, patchFromDictFileName != NULL);
if (memLimit == 0) { if (memLimit == 0) {