[Scummvm-cvs-logs] SF.net SVN: scummvm:[34492] scummvm/trunk/common
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Thu Sep 11 15:24:02 CEST 2008
Revision: 34492
http://scummvm.svn.sourceforge.net/scummvm/?rev=34492&view=rev
Author: peres001
Date: 2008-09-11 13:24:01 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Added first version of the SearchManager, as it is presented in patch tracker item 2093502.
Modified Paths:
--------------
scummvm/trunk/common/archive.cpp
scummvm/trunk/common/archive.h
Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp 2008-09-11 12:04:45 UTC (rev 34491)
+++ scummvm/trunk/common/archive.cpp 2008-09-11 13:24:01 UTC (rev 34492)
@@ -293,4 +293,38 @@
return 0;
}
+
+
+
+DECLARE_SINGLETON(SearchManager);
+
+void SearchManager::addArchive(const String &name, ArchivePtr archive) {
+ _searchSet.add(name, archive);
+}
+
+void SearchManager::addDirectory(const String &name, const String &directory) {
+ addDirectoryRecursive(name, 1);
+}
+
+void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth) {
+ _searchSet.add(name, SharedPtr<FSDirectory>(new FSDirectory(directory, depth)));
+}
+
+void SearchManager::remove(const String &name) {
+ _searchSet.remove(name);
+}
+
+void SearchManager::clear() {
+ _searchSet.clear();
+}
+
+bool SearchManager::hasFile(const String &name) {
+ return _searchSet.hasFile(name);
+}
+
+SeekableReadStream *SearchManager::openFile(const String &name) {
+ return _searchSet.openFile(name);
+}
+
+
} // namespace Common
Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h 2008-09-11 12:04:45 UTC (rev 34491)
+++ scummvm/trunk/common/archive.h 2008-09-11 13:24:01 UTC (rev 34492)
@@ -31,6 +31,7 @@
#include "common/hash-str.h"
#include "common/list.h"
#include "common/ptr.h"
+#include "common/singleton.h"
#include "common/stream.h"
namespace Common {
@@ -202,6 +203,56 @@
virtual SeekableReadStream *openFile(const String &name);
};
+
+
+
+class SearchManager : public Singleton<SearchManager>, public Archive {
+
+ SearchSet _searchSet;
+
+public:
+ /**
+ * Add an existing Archive. This is meant to support searching in system-specific
+ * archives, namely the MACOSX/IPHONE bundles.
+ */
+ void addArchive(const String &name, ArchivePtr archive);
+
+ /**
+ * Create and add a FSDirectory by name
+ */
+ void addDirectory(const String &name, const String &directory);
+
+ /**
+ * Create and add a FSDirectory and its subdirectories by name
+ */
+ void addDirectoryRecursive(const String &name, const String &directory, int depth = 4);
+
+ /**
+ * Remove an archive from the pool.
+ */
+ void remove(const String &name);
+
+ /**
+ * Clears the archive
+ */
+ void clear();
+
+
+ virtual bool hasFile(const String &name);
+ virtual int getAllNames(StringList &list) {
+ return matchPattern(list, "*");
+ }
+
+ /**
+ * Implements openFile from Archive base class. The current policy is
+ * opening the first file encountered that matches the name.
+ */
+ virtual SeekableReadStream *openFile(const String &name);
+};
+
+/** Shortcut for accessing the search manager. */
+#define SearchMan Common::SearchManager::instance()
+
} // namespace Common
#endif
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