FIO_decompressSrcFile() : Open `srcFileName`, transfer control to decompressDstFile() @return : 0 : OK 1 : error */
| 2546 | 1 : error |
| 2547 | */ |
| 2548 | static 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 |
no test coverage detected