From 38a44f85ae9c897c24d7e6ccbc165021ec191330 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 7 Sep 2008 21:30:55 +0000 Subject: Added new OSystem method addSysArchivesToSearchSet() [better name pending, suggestions welcome] svn-id: r34424 --- backends/platform/sdl/sdl.cpp | 36 ++++++++++++++++++++++++++++++++++++ backends/platform/sdl/sdl.h | 1 + 2 files changed, 37 insertions(+) (limited to 'backends') 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(); -- cgit v1.2.3