FIO_openSrcFile() : * condition : `srcFileName` must be non-NULL. * @result : FILE* to `srcFileName`, or NULL if it fails */
| 587 | * condition : `srcFileName` must be non-NULL. |
| 588 | * @result : FILE* to `srcFileName`, or NULL if it fails */ |
| 589 | static FILE* FIO_openSrcFile(const char* srcFileName) |
| 590 | { |
| 591 | stat_t statbuf; |
| 592 | assert(srcFileName != NULL); |
| 593 | if (!strcmp (srcFileName, stdinmark)) { |
| 594 | DISPLAYLEVEL(4,"Using stdin for input \n"); |
| 595 | SET_BINARY_MODE(stdin); |
| 596 | return stdin; |
| 597 | } |
| 598 | |
| 599 | if (!UTIL_stat(srcFileName, &statbuf)) { |
| 600 | DISPLAYLEVEL(1, "zstd: can't stat %s : %s -- ignored \n", |
| 601 | srcFileName, strerror(errno)); |
| 602 | return NULL; |
| 603 | } |
| 604 | |
| 605 | if (!UTIL_isRegularFileStat(&statbuf) |
| 606 | && !UTIL_isFIFOStat(&statbuf) |
| 607 | ) { |
| 608 | DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", |
| 609 | srcFileName); |
| 610 | return NULL; |
| 611 | } |
| 612 | |
| 613 | { FILE* const f = fopen(srcFileName, "rb"); |
| 614 | if (f == NULL) |
| 615 | DISPLAYLEVEL(1, "zstd: %s: %s \n", srcFileName, strerror(errno)); |
| 616 | return f; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /** FIO_openDstFile() : |
| 621 | * condition : `dstFileName` must be non-NULL. |
no test coverage detected