diff options
Diffstat (limited to 'common/archive.h')
-rw-r--r-- | common/archive.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/common/archive.h b/common/archive.h index 89ea6a5ce2..9103586d7d 100644 --- a/common/archive.h +++ b/common/archive.h @@ -93,21 +93,21 @@ typedef SharedPtr<Archive> ArchivePtr; * Searching is case-insensitive, as the main intended goal is supporting * retrieval of game data. First case-insensitive match is returned when * searching, thus making FSDirectory heavily dependant on the underlying - * FilesystemNode implementation. + * FSNode implementation. */ class FSDirectory : public Archive { - FilesystemNode _node; + FSNode _node; // Caches are case insensitive, clashes are dealt with when creating // Key is stored in lowercase. - typedef HashMap<String, FilesystemNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache; + typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache; NodeCache _fileCache, _subDirCache; // look for a match - FilesystemNode lookupCache(NodeCache &cache, const String &name); + FSNode lookupCache(NodeCache &cache, const String &name); // cache management - void cacheDirectoryRecursive(FilesystemNode node, int depth, const String& prefix); + void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix); bool _cached; int _depth; @@ -122,14 +122,14 @@ public: * Create a FSDirectory representing a tree with the specified depth. Will result in an * unbound FSDirectory if node does not exist or is not a directory. */ - FSDirectory(const FilesystemNode &node, int depth = 1); + FSDirectory(const FSNode &node, int depth = 1); virtual ~FSDirectory(); /** * This return the underlying FSNode of the FSDirectory. */ - FilesystemNode getFSNode() const; + FSNode getFSNode() const; /** * Create a new FSDirectory pointing to a sub directory of the instance. @@ -153,9 +153,12 @@ public: */ class SearchSet : public Archive { struct Node { - uint _priority; + int _priority; String _name; ArchivePtr _arc; + Node(int priority, const String &name, ArchivePtr arc) + : _priority(priority), _name(name), _arc(arc) { + } }; typedef List<Node> ArchiveList; ArchiveList _list; @@ -169,7 +172,7 @@ public: /** * Add a new archive to the searchable set. */ - void add(const String& name, ArchivePtr archive, uint priority = 0); + void add(const String& name, ArchivePtr archive, int priority = 0); /** * Remove an archive from the searchable set. @@ -184,12 +187,12 @@ public: /** * Empties the searchable set. */ - void clear(); + virtual void clear(); /** * Change the order of searches. */ - void setPriority(const String& name, uint priority); + void setPriority(const String& name, int priority); virtual bool hasFile(const String &name); virtual int matchPattern(StringList &list, const String &pattern); @@ -205,22 +208,28 @@ public: class SearchManager : public Singleton<SearchManager>, public SearchSet { public: + SearchManager(); + /** * 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); + void addArchive(const String &name, ArchivePtr archive, int priority = 0); /** * Create and add a FSDirectory by name */ - void addDirectory(const String &name, const String &directory); + void addDirectory(const String &name, const String &directory, int priority = 0); /** * Create and add a FSDirectory and its subdirectories by name */ - void addDirectoryRecursive(const String &name, const String &directory, int depth = 4); + void addDirectoryRecursive(const String &name, const String &directory, int depth = 4, int priority = 0); + /** + * TODO + */ + virtual void clear(); }; /** Shortcut for accessing the search manager. */ |