[Scummvm-cvs-logs] SF.net SVN: scummvm:[34424] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Sep 7 23:30:56 CEST 2008


Revision: 34424
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34424&view=rev
Author:   fingolfin
Date:     2008-09-07 21:30:55 +0000 (Sun, 07 Sep 2008)

Log Message:
-----------
Added new OSystem method addSysArchivesToSearchSet() [better name pending, suggestions welcome]

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/sdl/sdl.h
    scummvm/trunk/common/system.h

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-09-07 19:19:45 UTC (rev 34423)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-09-07 21:30:55 UTC (rev 34424)
@@ -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 @@
 	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__)

Modified: scummvm/trunk/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.h	2008-09-07 19:19:45 UTC (rev 34423)
+++ scummvm/trunk/backends/platform/sdl/sdl.h	2008-09-07 21:30:55 UTC (rev 34424)
@@ -209,6 +209,7 @@
 
 	virtual Common::SaveFileManager *getSavefileManager();
 	virtual FilesystemFactory *getFilesystemFactory();
+	virtual void addSysArchivesToSearchSet(Common::SearchSet &s);
 
 	virtual Common::SeekableReadStream *openConfigFileForReading();
 	virtual Common::WriteStream *openConfigFileForWriting();

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2008-09-07 19:19:45 UTC (rev 34423)
+++ scummvm/trunk/common/system.h	2008-09-07 21:30:55 UTC (rev 34424)
@@ -43,6 +43,7 @@
 	struct Event;
 	class EventManager;
 	class SaveFileManager;
+	class SearchSet;
 	class TimerManager;
 	class SeekableReadStream;
 	class WriteStream;
@@ -907,6 +908,17 @@
 	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.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list