diff options
author | Max Horn | 2008-09-07 21:30:55 +0000 |
---|---|---|
committer | Max Horn | 2008-09-07 21:30:55 +0000 |
commit | 38a44f85ae9c897c24d7e6ccbc165021ec191330 (patch) | |
tree | 2b972ac7639e3298c3da05d2d62ddd0d40af1802 | |
parent | f6c4df8281b00f92ccc040f99e33b28d933b9fa3 (diff) | |
download | scummvm-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
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 36 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 1 | ||||
-rw-r--r-- | common/system.h | 12 |
3 files changed, 49 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(); diff --git a/common/system.h b/common/system.h index 501d0802fd..b0e3e8ce14 100644 --- a/common/system.h +++ b/common/system.h @@ -43,6 +43,7 @@ namespace Common { struct Event; class EventManager; class SaveFileManager; + class SearchSet; class TimerManager; class SeekableReadStream; class WriteStream; @@ -907,6 +908,17 @@ public: virtual FilesystemFactory *getFilesystemFactory() = 0; /** + * Add system specific Common::Archive objects to the given SearchSet. + * E.g. on Unix the dir corresponding to DATA_PATH (if set), or on + * Mac OS X the 'Resource' dir in the app bundle. + * + * @todo Come up with a better name. This one sucks. + * + * @todo Allow specifying a priority with which the new dirs are added? + */ + virtual void addSysArchivesToSearchSet(Common::SearchSet &s) {} + + /** * Open the default config file for reading, by returning a suitable * ReadStream instance. It is the callers responsiblity to delete * the stream after use. |