aboutsummaryrefslogtreecommitdiff
path: root/common/file.cpp
diff options
context:
space:
mode:
authorOystein Eftevaag2006-03-15 07:43:44 +0000
committerOystein Eftevaag2006-03-15 07:43:44 +0000
commit58eed3830bfbea9a05b903c94a4331597fc90dc6 (patch)
treeb7e672c89b537b7f1637081323d822a8f741d47e /common/file.cpp
parent34b89a3258cd73087ad5b0a41ba82e7171094fd1 (diff)
downloadscummvm-rg350-58eed3830bfbea9a05b903c94a4331597fc90dc6.tar.gz
scummvm-rg350-58eed3830bfbea9a05b903c94a4331597fc90dc6.tar.bz2
scummvm-rg350-58eed3830bfbea9a05b903c94a4331597fc90dc6.zip
* 'make bundle' now copies the default theme files into the bundle.
* Common::File will now look inside the application bundle on MacOS X for a file if it can't find it anywhere else (so it'll find default-theme.ini and .zip) * Cleaned up some #ifs. svn-id: r21308
Diffstat (limited to 'common/file.cpp')
-rw-r--r--common/file.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/file.cpp b/common/file.cpp
index 871e4f6053..900edf966c 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -23,6 +23,10 @@
#include "common/file.h"
#include "common/util.h"
+#ifdef MACOSX
+#include "CoreFoundation/CoreFoundation.h"
+#endif
+
namespace Common {
StringList File::_defaultDirectories;
@@ -98,6 +102,24 @@ 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;
}