MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / File_Exists_Ex

Function File_Exists_Ex

src/file.c:635–657  ·  view source on GitHub ↗

* Check if a file exists either in a PAK or on the disk. * * @param dir directory for this file * @param filename The filename to check for. * @param fileSize Filled with the file size if the file exists * @return True if and only if the file can be found. */

Source from the content-addressed store, hash-verified

633 * @return True if and only if the file can be found.
634 */
635bool File_Exists_Ex(enum SearchDirectory dir, const char *filename, uint32 *fileSize)
636{
637 bool exists = false;
638
639 if(dir != SEARCHDIR_PERSONAL_DATA_DIR) {
640 FileInfo *fileInfo;
641 fileInfo = FileInfo_Find_ByName(filename, NULL);
642 if (fileInfo != NULL) {
643 exists = true;
644 if (fileSize != NULL) *fileSize = fileInfo->fileSize;
645 }
646 } else {
647 uint8 index;
648 index = _File_Open(dir, filename, FILE_MODE_READ);
649 if (index != FILE_INVALID) {
650 exists = true;
651 if (fileSize != NULL) *fileSize = File_GetSize(index);
652 File_Close(index);
653 }
654 }
655
656 return exists;
657}
658
659/**
660 * Open a file for reading/writing/appending.

Callers

nothing calls this directly

Calls 4

FileInfo_Find_ByNameFunction · 0.85
_File_OpenFunction · 0.85
File_GetSizeFunction · 0.85
File_CloseFunction · 0.85

Tested by

no test coverage detected