* 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. */
| 633 | * @return True if and only if the file can be found. |
| 634 | */ |
| 635 | bool 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. |
nothing calls this directly
no test coverage detected