aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2008-09-07 21:30:55 +0000
committerMax Horn2008-09-07 21:30:55 +0000
commit38a44f85ae9c897c24d7e6ccbc165021ec191330 (patch)
tree2b972ac7639e3298c3da05d2d62ddd0d40af1802 /backends
parentf6c4df8281b00f92ccc040f99e33b28d933b9fa3 (diff)
downloadscummvm-rg350-38a44f85ae9c897c24d7e6ccbc165021ec191330.tar.gz
scummvm-rg350-38a44f85ae9c897c24d7e6ccbc165021ec191330.tar.bz2
scummvm-rg350-38a44f85ae9c897c24d7e6ccbc165021ec191330.zip
Added new OSystem method addSysArchivesToSearchSet() [better name pending, suggestions welcome]
svn-id: r34424
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/sdl/sdl.cpp36
-rw-r--r--backends/platform/sdl/sdl.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 1332cbc16d..3423cd43c5 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -32,6 +32,7 @@
#endif
#include "backends/platform/sdl/sdl.h"
+#include "common/archive.h"
#include "common/config-manager.h"
#include "common/events.h"
#include "common/util.h"
@@ -71,6 +72,9 @@
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#endif
+#if defined(MACOSX) || defined(IPHONE)
+#include "CoreFoundation/CoreFoundation.h"
+#endif
static Uint32 timer_handler(Uint32 interval, void *param) {
@@ -271,6 +275,38 @@ FilesystemFactory *OSystem_SDL::getFilesystemFactory() {
return _fsFactory;
}
+void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s) {
+
+#ifdef DATA_PATH
+ // Add the global DATA_PATH to the directory search list
+ // FIXME: We use depth = 4 for now, to match the old code. May want to change that
+ Common::FilesystemNode dataNode(DATA_PATH);
+ if (dataNode.exists() && dataNode.isDirectory()) {
+ Common::ArchivePtr dataArchive(new Common::FSDirectory(dataNode, 4));
+ s.add(DATA_PATH, dataArchive);
+ }
+#endif
+
+#if defined(MACOSX) || defined(IPHONE)
+ // Get URL of the Resource directory of the .app bundle
+ CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
+ if (fileUrl) {
+ // Try to convert the URL to an absolute path
+ UInt8 buf[MAXPATHLEN];
+ if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) {
+ // Success: Add it to the search path
+ Common::String bundlePath((const char *)buf);
+ Common::ArchivePtr bundleArchive(new Common::FSDirectory(bundlePath));
+ s.add("__OSX_BUNDLE__", bundleArchive);
+ }
+ CFRelease(fileUrl);
+ }
+
+#endif
+
+}
+
+
static Common::String getDefaultConfigFileName() {
char configFile[MAXPATHLEN];
#if defined (WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index d07dcee679..f13cfafdaa 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -209,6 +209,7 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual FilesystemFactory *getFilesystemFactory();
+ virtual void addSysArchivesToSearchSet(Common::SearchSet &s);
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();