MCPcopy Create free account
hub / github.com/ConfettiFX/The-Forge / fsCheckPath

Function fsCheckPath

Common_3/Utilities/FileSystem/ToolFileSystem.c:777–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777bool fsCheckPath(ResourceDirectory rd, const char* path, bool* exist, bool* isDir, bool* isFile)
778{
779 const char* resourcePath = fsGetResourceDirectory(rd);
780 char fullPath[FS_MAX_PATH] = { 0 };
781 fsAppendPathComponent(resourcePath, path, fullPath);
782
783 // 'lstat' won't resolve symlink entries, so we use 'stat'.
784 // We are only interested in entry targeted by symlink
785 struct stat st = { 0 };
786 if (stat(fullPath, &st) == 0)
787 {
788 *exist = true;
789 *isDir = S_ISDIR(st.st_mode);
790 *isFile = S_ISREG(st.st_mode);
791 return true;
792 }
793
794 *exist = false;
795 *isDir = false;
796 *isFile = false;
797
798 if (errno == ENOENT)
799 return true;
800
801 LOGF(eERROR, "Failed to retreive path '%s' info: '%'", fullPath, strerror(errno));
802 return false;
803}
804
805bool fsDirectoryIteratorOpen(ResourceDirectory rd, const char* dir, FsDirectoryIterator* out)
806{

Callers 2

tryDragNdropFunction · 0.50

Calls 3

fsGetResourceDirectoryFunction · 0.85
fsAppendPathComponentFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected