Add fCtx to FIO_openDstFile()

This commit is contained in:
senhuang42 2020-09-24 15:49:30 -04:00
parent 21cd640b93
commit 0e8ac6b995
2 changed files with 6 additions and 9 deletions

View File

@ -603,7 +603,7 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
* condition : `dstFileName` must be non-NULL.
* @result : FILE* to `dstFileName`, or NULL if it fails */
static FILE*
FIO_openDstFile(FIO_prefs_t* const prefs,
FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
const char* srcFileName, const char* dstFileName)
{
if (prefs->testMode) return NULL; /* do not open file in test mode */
@ -1566,7 +1566,7 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
if (ress.dstFile == NULL) {
closeDstFile = 1;
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: opening dst: %s \n", dstFileName);
ress.dstFile = FIO_openDstFile(prefs, srcFileName, dstFileName);
ress.dstFile = FIO_openDstFile(fCtx, prefs, srcFileName, dstFileName);
if (ress.dstFile==NULL) return 1; /* could not open dstFileName */
/* Must only be added after FIO_openDstFile() succeeds.
* Otherwise we may delete the destination file if it already exists,
@ -1773,7 +1773,7 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx,
FIO_freeCResources(ress);
return 1;
}
ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName);
ress.dstFile = FIO_openDstFile(fCtx, prefs, NULL, outFileName);
if (ress.dstFile == NULL) { /* could not open outFileName */
error = 1;
} else {
@ -2458,7 +2458,7 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
if ((ress.dstFile == NULL) && (prefs->testMode==0)) {
releaseDstFile = 1;
ress.dstFile = FIO_openDstFile(prefs, srcFileName, dstFileName);
ress.dstFile = FIO_openDstFile(fCtx, prefs, srcFileName, dstFileName);
if (ress.dstFile==NULL) return 1;
/* Must only be added after FIO_openDstFile() succeeds.
@ -2688,7 +2688,7 @@ FIO_decompressMultipleFilenames(FIO_ctx_t* const fCtx,
return 1;
}
if (!prefs->testMode) {
ress.dstFile = FIO_openDstFile(prefs, NULL, outFileName);
ress.dstFile = FIO_openDstFile(fCtx, prefs, NULL, outFileName);
if (ress.dstFile == 0) EXM_THROW(19, "cannot open %s", outFileName);
}
for (; fCtx->currFileIdx < fCtx->nbFilesTotal; fCtx->currFileIdx++) {

View File

@ -90,9 +90,6 @@ int g_utilDisplayLevel;
int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
const char* acceptableLetters) {
int ch, result;
/* If input is presented via stdin, dont use prompt as it may swallow characters */
if (!IS_CONSOLE(stdin))
return 0;
UTIL_DISPLAY("%s", prompt);
ch = getchar();