-************************************* * Functions ***************************************/ FIO_removeFile() : * @result : Unlink `fileName`, even if it's read-only */
| 563 | /** FIO_removeFile() : |
| 564 | * @result : Unlink `fileName`, even if it's read-only */ |
| 565 | static 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. |
no test coverage detected