Tells if the file exists Returns non-zero if file exists. Also tells if the file is on disk or in a hog - See return values in cfile.h
| 632 | // Returns non-zero if file exists. Also tells if the file is on disk |
| 633 | // or in a hog - See return values in cfile.h |
| 634 | int cfexist(const std::filesystem::path &filename) { |
| 635 | CFILE *cfp; |
| 636 | int ret; |
| 637 | |
| 638 | cfp = cfopen(filename, "rb"); |
| 639 | if (!cfp) { // Didn't get file. Why? |
| 640 | if (errno == EACCES) // File exists, but couldn't open it |
| 641 | return CFES_ON_DISK; // so say it exists on the disk |
| 642 | |
| 643 | return CFES_NOT_FOUND; // Say we didn't find the file |
| 644 | } |
| 645 | ret = cfp->lib_offset ? CFES_IN_LIBRARY : CFES_ON_DISK; |
| 646 | cfclose(cfp); |
| 647 | return ret; |
| 648 | } |
| 649 | // Reads the specified number of bytes from a file into the buffer |
| 650 | // DO NOT USE THIS TO READ STRUCTURES. This function is for byte |
| 651 | // data, such as a string or a bitmap of 8-bit pixels. |
no test coverage detected