| 2717 | } |
| 2718 | |
| 2719 | int |
| 2720 | FIO_decompressMultipleFilenames(FIO_ctx_t* const fCtx, |
| 2721 | FIO_prefs_t* const prefs, |
| 2722 | const char** srcNamesTable, |
| 2723 | const char* outMirroredRootDirName, |
| 2724 | const char* outDirName, const char* outFileName, |
| 2725 | const char* dictFileName) |
| 2726 | { |
| 2727 | int status; |
| 2728 | int error = 0; |
| 2729 | dRess_t ress = FIO_createDResources(prefs, dictFileName); |
| 2730 | |
| 2731 | if (outFileName) { |
| 2732 | if (FIO_removeMultiFilesWarning(fCtx, prefs, outFileName, 1 /* displayLevelCutoff */)) { |
| 2733 | FIO_freeDResources(ress); |
| 2734 | return 1; |
| 2735 | } |
| 2736 | if (!prefs->testMode) { |
| 2737 | ress.dstFile = FIO_openDstFile(fCtx, prefs, NULL, outFileName); |
| 2738 | if (ress.dstFile == 0) EXM_THROW(19, "cannot open %s", outFileName); |
| 2739 | } |
| 2740 | for (; fCtx->currFileIdx < fCtx->nbFilesTotal; fCtx->currFileIdx++) { |
| 2741 | status = FIO_decompressSrcFile(fCtx, prefs, ress, outFileName, srcNamesTable[fCtx->currFileIdx]); |
| 2742 | if (!status) fCtx->nbFilesProcessed++; |
| 2743 | error |= status; |
| 2744 | } |
| 2745 | if ((!prefs->testMode) && (fclose(ress.dstFile))) |
| 2746 | EXM_THROW(72, "Write error : %s : cannot properly close output file", |
| 2747 | strerror(errno)); |
| 2748 | } else { |
| 2749 | if (outMirroredRootDirName) |
| 2750 | UTIL_mirrorSourceFilesDirectories(srcNamesTable, fCtx->nbFilesTotal, outMirroredRootDirName); |
| 2751 | |
| 2752 | for (; fCtx->currFileIdx < fCtx->nbFilesTotal; fCtx->currFileIdx++) { /* create dstFileName */ |
| 2753 | const char* const srcFileName = srcNamesTable[fCtx->currFileIdx]; |
| 2754 | const char* dstFileName = NULL; |
| 2755 | if (outMirroredRootDirName) { |
| 2756 | char* validMirroredDirName = UTIL_createMirroredDestDirName(srcFileName, outMirroredRootDirName); |
| 2757 | if (validMirroredDirName) { |
| 2758 | dstFileName = FIO_determineDstName(srcFileName, validMirroredDirName); |
| 2759 | free(validMirroredDirName); |
| 2760 | } else { |
| 2761 | DISPLAYLEVEL(2, "zstd: --output-dir-mirror cannot decompress '%s' into '%s'\n", srcFileName, outMirroredRootDirName); |
| 2762 | } |
| 2763 | } else { |
| 2764 | dstFileName = FIO_determineDstName(srcFileName, outDirName); |
| 2765 | } |
| 2766 | if (dstFileName == NULL) { error=1; continue; } |
| 2767 | status = FIO_decompressSrcFile(fCtx, prefs, ress, dstFileName, srcFileName); |
| 2768 | if (!status) fCtx->nbFilesProcessed++; |
| 2769 | error |= status; |
| 2770 | } |
| 2771 | if (outDirName) |
| 2772 | FIO_checkFilenameCollisions(srcNamesTable , fCtx->nbFilesTotal); |
| 2773 | } |
| 2774 | |
| 2775 | if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesOutput != 0) |
| 2776 | DISPLAYLEVEL(2, "%d files decompressed : %6zu bytes total \n", fCtx->nbFilesProcessed, fCtx->totalBytesOutput); |
no test coverage detected