MCPcopy Create free account
hub / github.com/F-Stack/f-stack / FIO_decompressSrcFile

Function FIO_decompressSrcFile

freebsd/contrib/zstd/programs/fileio.c:2548–2582  ·  view source on GitHub ↗

FIO_decompressSrcFile() : Open `srcFileName`, transfer control to decompressDstFile() @return : 0 : OK 1 : error */

Source from the content-addressed store, hash-verified

2546 1 : error
2547*/
2548static int FIO_decompressSrcFile(FIO_ctx_t* const fCtx, FIO_prefs_t* const prefs, dRess_t ress, const char* dstFileName, const char* srcFileName)
2549{
2550 FILE* srcFile;
2551 int result;
2552
2553 if (UTIL_isDirectory(srcFileName)) {
2554 DISPLAYLEVEL(1, "zstd: %s is a directory -- ignored \n", srcFileName);
2555 return 1;
2556 }
2557
2558 srcFile = FIO_openSrcFile(srcFileName);
2559 if (srcFile==NULL) return 1;
2560 ress.srcBufferLoaded = 0;
2561
2562 result = FIO_decompressDstFile(fCtx, prefs, ress, srcFile, dstFileName, srcFileName);
2563
2564 /* Close file */
2565 if (fclose(srcFile)) {
2566 DISPLAYLEVEL(1, "zstd: %s: %s \n", srcFileName, strerror(errno)); /* error should not happen */
2567 return 1;
2568 }
2569 if ( prefs->removeSrcFile /* --rm */
2570 && (result==0) /* decompression successful */
2571 && strcmp(srcFileName, stdinmark) ) /* not stdin */ {
2572 /* We must clear the handler, since after this point calling it would
2573 * delete both the source and destination files.
2574 */
2575 clearHandler();
2576 if (FIO_removeFile(srcFileName)) {
2577 /* failed to remove src file */
2578 DISPLAYLEVEL(1, "zstd: %s: %s \n", srcFileName, strerror(errno));
2579 return 1;
2580 } }
2581 return result;
2582}
2583
2584
2585

Callers 2

FIO_decompressFilenameFunction · 0.85

Calls 6

UTIL_isDirectoryFunction · 0.85
FIO_openSrcFileFunction · 0.85
FIO_decompressDstFileFunction · 0.85
strcmpFunction · 0.85
clearHandlerFunction · 0.85
FIO_removeFileFunction · 0.85

Tested by

no test coverage detected