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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Oct 22 19:08:18 CEST 2008


Revision: 34836
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34836&view=rev
Author:   fingolfin
Date:     2008-10-22 17:08:17 +0000 (Wed, 22 Oct 2008)

Log Message:
-----------
Removed File::addDefaultDirectoryRecursive, tweaked SearchMan API slightly

Modified Paths:
--------------
    scummvm/trunk/base/main.cpp
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/archive.h
    scummvm/trunk/common/file.cpp
    scummvm/trunk/common/file.h

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2008-10-21 18:13:35 UTC (rev 34835)
+++ scummvm/trunk/base/main.cpp	2008-10-22 17:08:17 UTC (rev 34836)
@@ -171,6 +171,13 @@
 		system.setWindowCaption(caption.c_str());
 	}
 
+	//
+	// Setup varios paths in the SearchManager
+	//
+	Common::FSNode dir;
+
+	// Add the game path to the directory search list
+	//
 	// FIXME: at this moment, game path handling is being discussed in the mailing list,
 	// while Common::File is being reworked under the hood. After commit 34444, which
 	// changed the implementation of Common::File (specifically removing usage of fopen
@@ -178,23 +185,21 @@
 	// stopped working. Example of this are the HE games which use subdirectories: Kirben
 	// found this issue on lost-win-demo at first. Thus, in commit 34450, searching the
 	// game path was made recursive as a temporary fix/workaround.
+	dir = Common::FSNode(path);
+	SearchMan.addDirectory(dir.getPath(), dir);
 
-	// Add the game path to the directory search list
-	Common::File::addDefaultDirectoryRecursive(path);
-
 	// Add extrapath (if any) to the directory search list
-	if (ConfMan.hasKey("extrapath"))
-		Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
+	if (ConfMan.hasKey("extrapath")) {
+		dir = Common::FSNode(ConfMan.get("extrapath"));
+		SearchMan.addDirectory(dir.getPath(), dir);
+	}
 
 	// If a second extrapath is specified on the app domain level, add that as well.
-	if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain))
-		Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain));
+	if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
+		dir = Common::FSNode(ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain));
+		SearchMan.addDirectory(dir.getPath(), dir);
+	}
 
-#ifdef DATA_PATH
-	// Add the global DATA_PATH to the directory search list
-	Common::File::addDefaultDirectoryRecursive(DATA_PATH);
-#endif
-
 	// On creation the engine should've set up all debug levels so we can use
 	// the command line arugments here
 	Common::enableSpecialDebugLevelList(edebuglevels);
@@ -223,7 +228,7 @@
 	delete engine;
 
 	// Reset the file/directory mappings
-	Common::File::resetDefaultDirectories();
+	SearchMan.clear();
 
 	// Return result (== 0 means no error)
 	return result;

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2008-10-21 18:13:35 UTC (rev 34835)
+++ scummvm/trunk/common/archive.cpp	2008-10-22 17:08:17 UTC (rev 34836)
@@ -382,12 +382,16 @@
 	clear();	// Force a reset
 }
 
-void SearchManager::addDirectory(const String &name, const String &directory, int priority) {
-	addDirectoryRecursive(name, directory, 1, priority);
+void SearchManager::addDirectory(const String &name, const String &directory, int priority, int depth) {
+	FSNode dir(directory);
+	addDirectory(name, dir, priority, depth);
 }
 
-void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth, int priority) {
-	add(name, ArchivePtr(new FSDirectory(directory, depth)), priority);
+void SearchManager::addDirectory(const String &name, const FSNode &dir, int priority, int depth) {
+	if (!dir.exists() || !dir.isDirectory())
+		return;
+
+	add(name, ArchivePtr(new FSDirectory(dir, depth)), priority);
 }
 
 void SearchManager::clear() {
@@ -400,7 +404,7 @@
 
 	// Add the current dir as a very last resort.
 	// See also bug #2137680.
-	add(".", ArchivePtr(new FSDirectory(".")), -2);
+	addDirectory(".", ".", -2);
 }
 
 } // namespace Common

Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h	2008-10-21 18:13:35 UTC (rev 34835)
+++ scummvm/trunk/common/archive.h	2008-10-22 17:08:17 UTC (rev 34836)
@@ -288,15 +288,16 @@
 	/**
 	 * Create and add a FSDirectory by name
 	 */
-	void addDirectory(const String &name, const String &directory, int priority = 0);
+	void addDirectory(const String &name, const String &directory, int priority = 0, int depth = 1);
 
 	/**
-	 * Create and add a FSDirectory and its subdirectories by name
+	 * Create and add a FSDirectory by FSNode
 	 */
-	void addDirectoryRecursive(const String &name, const String &directory, int depth = 4, int priority = 0);
+	void addDirectory(const String &name, const FSNode &directory, int priority = 0, int depth = 1);
 
 	/**
-	 * TODO
+	 * Resets the search manager to the default list of search paths (system
+	 * specific dirs + current dir).
 	 */
 	virtual void clear();
 };

Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp	2008-10-21 18:13:35 UTC (rev 34835)
+++ scummvm/trunk/common/file.cpp	2008-10-22 17:08:17 UTC (rev 34836)
@@ -33,30 +33,13 @@
 
 void File::addDefaultDirectory(const String &directory) {
 	FSNode dir(directory);
-	addDefaultDirectoryRecursive(dir, 1);
+	addDefaultDirectory(dir);
 }
 
-void File::addDefaultDirectoryRecursive(const String &directory, int level) {
-	FSNode dir(directory);
-	addDefaultDirectoryRecursive(dir, level);
+void File::addDefaultDirectory(const FSNode &dir) {
+	SearchMan.addDirectory(dir.getPath(), dir);
 }
 
-void File::addDefaultDirectory(const FSNode &directory) {
-	addDefaultDirectoryRecursive(directory, 1);
-}
-
-void File::addDefaultDirectoryRecursive(const FSNode &dir, int level) {
-	if (level <= 0 || !dir.exists() || !dir.isDirectory())
-		return;
-
-	Common::ArchivePtr dataArchive(new Common::FSDirectory(dir, level));
-	SearchMan.add(dir.getPath(), dataArchive);
-}
-
-void File::resetDefaultDirectories() {
-	SearchMan.clear();
-}
-
 File::File()
 	: _handle(0) {
 }

Modified: scummvm/trunk/common/file.h
===================================================================
--- scummvm/trunk/common/file.h	2008-10-21 18:13:35 UTC (rev 34835)
+++ scummvm/trunk/common/file.h	2008-10-22 17:08:17 UTC (rev 34836)
@@ -50,14 +50,8 @@
 public:
 
 	static void addDefaultDirectory(const String &directory);
-	static void addDefaultDirectoryRecursive(const String &directory, int level = 4);
-
 	static void addDefaultDirectory(const FSNode &directory);
-	static void addDefaultDirectoryRecursive(const FSNode &directory, int level = 4);
 
-	static void resetDefaultDirectories();
-
-
 	File();
 	virtual ~File();
 


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