From 166386b581195acbac82ac984264fa9e9de5ada1 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 11 Sep 2008 13:24:01 +0000 Subject: Added first version of the SearchManager, as it is presented in patch tracker item 2093502. svn-id: r34492 --- common/archive.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'common/archive.h') diff --git a/common/archive.h b/common/archive.h index ac68a7f33d..c418eae063 100644 --- a/common/archive.h +++ b/common/archive.h @@ -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 @@ public: virtual SeekableReadStream *openFile(const String &name); }; + + + +class SearchManager : public Singleton, 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 -- cgit v1.2.3