diff options
author | Willem Jan Palenstijn | 2009-06-01 00:01:32 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2009-06-01 00:01:32 +0000 |
commit | 6e382592702534bb530f5610f19f694d3b4e5429 (patch) | |
tree | 2ab7746b3970483790cb6ceca634427a3c6720cc /common/fs.h | |
parent | 9c8c1cb080a72fd143ef6db50f1ab2fd27a6d009 (diff) | |
download | scummvm-rg350-6e382592702534bb530f5610f19f694d3b4e5429.tar.gz scummvm-rg350-6e382592702534bb530f5610f19f694d3b4e5429.tar.bz2 scummvm-rg350-6e382592702534bb530f5610f19f694d3b4e5429.zip |
Add a 'flat' option to FSDirectory to allow searching recursively for files in subdirectories
svn-id: r41090
Diffstat (limited to 'common/fs.h')
-rw-r--r-- | common/fs.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/common/fs.h b/common/fs.h index 1dcd07b1cf..d0e3c23558 100644 --- a/common/fs.h +++ b/common/fs.h @@ -232,8 +232,8 @@ public: * * FSDirectory can represent a single directory, or a tree with specified depth, * depending on the value passed to the 'depth' parameter in the constructors. - * Filenames are cached with their relative path, with elements separated by - * slashes, e.g.: + * In the default mode, filenames are cached with their relative path, + * with elements separated by slashes, e.g.: * * c:\my\data\file.ext * @@ -247,11 +247,16 @@ public: * hasFile(), listMatchingMembers() and listMembers(). Please see the function * specific comments for more information. * + * If the 'flat' argument to the constructor is true, files in subdirectories + * are cached without the relative path, so in the example above + * c:\my\data\file.ext would be cached as file.ext. + * * Client code can customize cache by using the constructors with the 'prefix' * parameter. In this case, the prefix is prepended to each entry in the cache, * and effectively treated as a 'virtual' parent subdirectory. FSDirectory adds * a trailing slash to prefix if needed. Following on with the previous example * and using 'your' as prefix, the cache entry would have been 'your/data/file.ext'. + * This is done both in non-flat and flat mode. * */ class FSDirectory : public Archive { @@ -266,6 +271,7 @@ class FSDirectory : public Archive { mutable NodeCache _fileCache, _subDirCache; mutable bool _cached; mutable int _depth; + mutable bool _flat; // look for a match FSNode *lookupCache(NodeCache &cache, const String &name) const; @@ -282,15 +288,17 @@ public: * unbound FSDirectory if name is not found on the filesystem or if the node is not a * valid directory. */ - FSDirectory(const String &name, int depth = 1); - FSDirectory(const FSNode &node, int depth = 1); + FSDirectory(const String &name, int depth = 1, bool flat = false); + FSDirectory(const FSNode &node, int depth = 1, bool flat = false); /** * Create a FSDirectory representing a tree with the specified depth. The parameter * prefix is prepended to the keys in the cache. See class comment. */ - FSDirectory(const String &prefix, const String &name, int depth = 1); - FSDirectory(const String &prefix, const FSNode &node, int depth = 1); + FSDirectory(const String &prefix, const String &name, int depth = 1, + bool flat = false); + FSDirectory(const String &prefix, const FSNode &node, int depth = 1, + bool flat = false); virtual ~FSDirectory(); @@ -304,8 +312,8 @@ public: * for an explanation of the prefix parameter. * @return a new FSDirectory instance */ - FSDirectory *getSubDirectory(const String &name, int depth = 1); - FSDirectory *getSubDirectory(const String &prefix, const String &name, int depth = 1); + FSDirectory *getSubDirectory(const String &name, int depth = 1, bool flat = false); + FSDirectory *getSubDirectory(const String &prefix, const String &name, int depth = 1, bool flat = false); /** * Checks for existence in the cache. A full match of relative path and filename is needed |