MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / cfexist

Function cfexist

cfile/cfile.cpp:634–648  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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
634int 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.

Callers 15

TableVersionCurrentFunction · 0.85
mng_InitTableFilesFunction · 0.85
mng_BackupTableFileFunction · 0.85
UpdatePrimitiveFunction · 0.85
mng_SetAddonTableFunction · 0.85
OnCompileMethod · 0.85
OnEditscriptMethod · 0.85
OnCreatescriptMethod · 0.85
Step3Method · 0.85

Calls 2

cfopenFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected