diff options
author | Oystein Eftevaag | 2006-03-15 09:41:22 +0000 |
---|---|---|
committer | Oystein Eftevaag | 2006-03-15 09:41:22 +0000 |
commit | dabfcbf10c6bd6048f677017402ec335bb3c60e9 (patch) | |
tree | 3a537788f567a581624fd2bfef25482742213d50 /common | |
parent | 58eed3830bfbea9a05b903c94a4331597fc90dc6 (diff) | |
download | scummvm-rg350-dabfcbf10c6bd6048f677017402ec335bb3c60e9.tar.gz scummvm-rg350-dabfcbf10c6bd6048f677017402ec335bb3c60e9.tar.bz2 scummvm-rg350-dabfcbf10c6bd6048f677017402ec335bb3c60e9.zip |
Moving the MacOS bundle file checking to another function, it was getting called redundantly.
svn-id: r21309
Diffstat (limited to 'common')
-rw-r--r-- | common/file.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/common/file.cpp b/common/file.cpp index 900edf966c..8d0658818b 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -102,24 +102,6 @@ static FILE *fopenNoCase(const char *filename, const char *directory, const char } #endif -// If all else fails, try looking inside the application bundle on MacOS for the lowercase file. -#ifdef MACOSX - if (!file) { - ptr = buf + offsetToFileName; - while (*ptr) { - *ptr = tolower(*ptr); - ptr++; - } - - CFStringRef fileName = CFStringCreateWithBytes(NULL, (const UInt8 *)buf, strlen(buf), kCFStringEncodingASCII, false); - CFURLRef fileUrl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), fileName, NULL, NULL); - if (fileUrl) { - if (CFURLGetFileSystemRepresentation(fileUrl, true, (UInt8 *)buf, sizeof(buf))) - file = fopen(buf, mode); - } - } -#endif - return file; } @@ -185,6 +167,21 @@ bool File::open(const char *filename, AccessMode mode, const char *directory) { // Last resort: try the current directory if (_handle == NULL) _handle = fopenNoCase(filename, "", modeStr); + + // Last last (really) resort: try looking inside the application bundle on MacOS for the lowercase file. +#ifdef MACOSX + if (!_handle) { + CFStringRef cfFileName = CFStringCreateWithBytes(NULL, (const UInt8 *)filename, strlen(filename), kCFStringEncodingASCII, false); + CFURLRef fileUrl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), cfFileName, NULL, NULL); + if (fileUrl) { + UInt8 buf[256]; + if (CFURLGetFileSystemRepresentation(fileUrl, false, (UInt8 *)buf, 256)) { + _handle = fopen((char *)buf, modeStr); + } + } + } +#endif + } if (_handle == NULL) { |