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

Function FIO_openSrcFile

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

FIO_openSrcFile() : * condition : `srcFileName` must be non-NULL. * @result : FILE* to `srcFileName`, or NULL if it fails */

Source from the content-addressed store, hash-verified

587 * condition : `srcFileName` must be non-NULL.
588 * @result : FILE* to `srcFileName`, or NULL if it fails */
589static 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.

Callers 3

FIO_decompressSrcFileFunction · 0.85

Calls 4

strcmpFunction · 0.85
UTIL_statFunction · 0.85
UTIL_isRegularFileStatFunction · 0.85
UTIL_isFIFOStatFunction · 0.85

Tested by

no test coverage detected