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

Function FIO_removeFile

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

-************************************* * Functions ***************************************/ FIO_removeFile() : * @result : Unlink `fileName`, even if it's read-only */

Source from the content-addressed store, hash-verified

563/** FIO_removeFile() :
564 * @result : Unlink `fileName`, even if it's read-only */
565static int FIO_removeFile(const char* path)
566{
567 stat_t statbuf;
568 if (!UTIL_stat(path, &statbuf)) {
569 DISPLAYLEVEL(2, "zstd: Failed to stat %s while trying to remove it\n", path);
570 return 0;
571 }
572 if (!UTIL_isRegularFileStat(&statbuf)) {
573 DISPLAYLEVEL(2, "zstd: Refusing to remove non-regular file %s\n", path);
574 return 0;
575 }
576#if defined(_WIN32) || defined(WIN32)
577 /* windows doesn't allow remove read-only files,
578 * so try to make it writable first */
579 if (!(statbuf.st_mode & _S_IWRITE)) {
580 UTIL_chmod(path, &statbuf, _S_IWRITE);
581 }
582#endif
583 return remove(path);
584}
585
586/** FIO_openSrcFile() :
587 * condition : `srcFileName` must be non-NULL.

Callers 5

FIO_openDstFileFunction · 0.85
FIO_decompressDstFileFunction · 0.85
FIO_decompressSrcFileFunction · 0.85

Calls 3

UTIL_statFunction · 0.85
UTIL_isRegularFileStatFunction · 0.85
UTIL_chmodFunction · 0.85

Tested by

no test coverage detected