Fix 1 file multifile logic, remove unnecessary variable assignments
This commit is contained in:
+8
-14
@@ -1751,7 +1751,7 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
const char* dictFileName, int compressionLevel,
|
const char* dictFileName, int compressionLevel,
|
||||||
ZSTD_compressionParameters comprParams)
|
ZSTD_compressionParameters comprParams)
|
||||||
{
|
{
|
||||||
int error = 0, status = 0;
|
int error = 0, status;
|
||||||
cRess_t ress = FIO_createCResources(prefs, dictFileName,
|
cRess_t ress = FIO_createCResources(prefs, dictFileName,
|
||||||
FIO_getLargestFileSize(inFileNamesTable, fCtx->nbFilesTotal),
|
FIO_getLargestFileSize(inFileNamesTable, fCtx->nbFilesTotal),
|
||||||
compressionLevel, comprParams);
|
compressionLevel, comprParams);
|
||||||
@@ -1765,7 +1765,7 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
} else {
|
} else {
|
||||||
for (; fCtx->currFileIdx < fCtx->nbFilesTotal; ++fCtx->currFileIdx) {
|
for (; fCtx->currFileIdx < fCtx->nbFilesTotal; ++fCtx->currFileIdx) {
|
||||||
status = FIO_compressFilename_srcFile(prefs, fCtx, ress, outFileName, inFileNamesTable[fCtx->currFileIdx], compressionLevel);
|
status = FIO_compressFilename_srcFile(prefs, fCtx, ress, outFileName, inFileNamesTable[fCtx->currFileIdx], compressionLevel);
|
||||||
fCtx->nbFilesProcessed = status ? fCtx->nbFilesProcessed : fCtx->nbFilesProcessed + 1;
|
if (!status) fCtx->nbFilesProcessed++;
|
||||||
error |= status;
|
error |= status;
|
||||||
}
|
}
|
||||||
if (fclose(ress.dstFile))
|
if (fclose(ress.dstFile))
|
||||||
@@ -1794,7 +1794,7 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
dstFileName = FIO_determineCompressedName(srcFileName, outDirName, suffix); /* cannot fail */
|
dstFileName = FIO_determineCompressedName(srcFileName, outDirName, suffix); /* cannot fail */
|
||||||
}
|
}
|
||||||
status = FIO_compressFilename_srcFile(prefs, fCtx, ress, dstFileName, srcFileName, compressionLevel);
|
status = FIO_compressFilename_srcFile(prefs, fCtx, ress, dstFileName, srcFileName, compressionLevel);
|
||||||
fCtx->nbFilesProcessed = status ? fCtx->nbFilesProcessed : fCtx->nbFilesProcessed + 1;
|
if (!status) fCtx->nbFilesProcessed++;
|
||||||
error |= status;
|
error |= status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1802,16 +1802,10 @@ int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
FIO_checkFilenameCollisions(inFileNamesTable , fCtx->nbFilesTotal);
|
FIO_checkFilenameCollisions(inFileNamesTable , fCtx->nbFilesTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fCtx->nbFilesProcessed > 1) {
|
if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0)
|
||||||
if (fCtx->totalBytesInput != 0) {
|
|
||||||
DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu bytes)\n", fCtx->nbFilesProcessed,
|
DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu bytes)\n", fCtx->nbFilesProcessed,
|
||||||
(double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100,
|
(double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100,
|
||||||
fCtx->totalBytesInput, fCtx->totalBytesOutput);
|
fCtx->totalBytesInput, fCtx->totalBytesOutput);
|
||||||
} else {
|
|
||||||
DISPLAYLEVEL(2, "%d files compressed : (%6zu => %6zu bytes)\n", fCtx->nbFilesProcessed,
|
|
||||||
fCtx->totalBytesInput, fCtx->totalBytesOutput);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FIO_freeCResources(ress);
|
FIO_freeCResources(ress);
|
||||||
return error;
|
return error;
|
||||||
@@ -2673,7 +2667,7 @@ FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
const char* outDirName, const char* outFileName,
|
const char* outDirName, const char* outFileName,
|
||||||
const char* dictFileName)
|
const char* dictFileName)
|
||||||
{
|
{
|
||||||
int error = 0, status = 0;
|
int error = 0, status;
|
||||||
dRess_t ress = FIO_createDResources(prefs, dictFileName);
|
dRess_t ress = FIO_createDResources(prefs, dictFileName);
|
||||||
|
|
||||||
if (outFileName) {
|
if (outFileName) {
|
||||||
@@ -2683,7 +2677,7 @@ FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
}
|
}
|
||||||
for (; fCtx->currFileIdx < fCtx->nbFilesTotal; fCtx->currFileIdx++) {
|
for (; fCtx->currFileIdx < fCtx->nbFilesTotal; fCtx->currFileIdx++) {
|
||||||
status = FIO_decompressSrcFile(prefs, fCtx, ress, outFileName, srcNamesTable[fCtx->currFileIdx]);
|
status = FIO_decompressSrcFile(prefs, fCtx, ress, outFileName, srcNamesTable[fCtx->currFileIdx]);
|
||||||
fCtx->nbFilesProcessed = status ? fCtx->nbFilesProcessed : fCtx->nbFilesProcessed + 1;
|
if (!status) fCtx->nbFilesProcessed++;
|
||||||
error |= status;
|
error |= status;
|
||||||
}
|
}
|
||||||
if ((!prefs->testMode) && (fclose(ress.dstFile)))
|
if ((!prefs->testMode) && (fclose(ress.dstFile)))
|
||||||
@@ -2709,14 +2703,14 @@ FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
|
|||||||
}
|
}
|
||||||
if (dstFileName == NULL) { error=1; continue; }
|
if (dstFileName == NULL) { error=1; continue; }
|
||||||
status = FIO_decompressSrcFile(prefs, fCtx, ress, dstFileName, srcFileName);
|
status = FIO_decompressSrcFile(prefs, fCtx, ress, dstFileName, srcFileName);
|
||||||
fCtx->nbFilesProcessed = status ? fCtx->nbFilesProcessed : fCtx->nbFilesProcessed + 1;
|
if (!status) fCtx->nbFilesProcessed++;
|
||||||
error |= status;
|
error |= status;
|
||||||
}
|
}
|
||||||
if (outDirName)
|
if (outDirName)
|
||||||
FIO_checkFilenameCollisions(srcNamesTable , fCtx->nbFilesTotal);
|
FIO_checkFilenameCollisions(srcNamesTable , fCtx->nbFilesTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fCtx->nbFilesProcessed > 1)
|
if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0)
|
||||||
DISPLAYLEVEL(2, "%d files decompressed : %6zu bytes total \n", fCtx->nbFilesProcessed, fCtx->totalBytesOutput);
|
DISPLAYLEVEL(2, "%d files decompressed : %6zu bytes total \n", fCtx->nbFilesProcessed, fCtx->totalBytesOutput);
|
||||||
|
|
||||||
FIO_freeDResources(ress);
|
FIO_freeDResources(ress);
|
||||||
|
|||||||
Reference in New Issue
Block a user