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.cpp | |
| 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.cpp')
| -rw-r--r-- | common/fs.cpp | 31 | 
1 files changed, 17 insertions, 14 deletions
| diff --git a/common/fs.cpp b/common/fs.cpp index 2f1347226f..742177ea4a 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -163,22 +163,22 @@ Common::WriteStream *FSNode::createWriteStream() const {  	return _realNode->createWriteStream();  } -FSDirectory::FSDirectory(const FSNode &node, int depth) -  : _node(node), _cached(false), _depth(depth) { +FSDirectory::FSDirectory(const FSNode &node, int depth, bool flat) +  : _node(node), _cached(false), _depth(depth), _flat(flat) {  } -FSDirectory::FSDirectory(const String &prefix, const FSNode &node, int depth) -  : _node(node), _cached(false), _depth(depth) { +FSDirectory::FSDirectory(const String &prefix, const FSNode &node, int depth, bool flat) +  : _node(node), _cached(false), _depth(depth), _flat(flat) {  	setPrefix(prefix);  } -FSDirectory::FSDirectory(const String &name, int depth) -  : _node(name), _cached(false), _depth(depth) { +FSDirectory::FSDirectory(const String &name, int depth, bool flat) +  : _node(name), _cached(false), _depth(depth), _flat(flat) {  } -FSDirectory::FSDirectory(const String &prefix, const String &name, int depth) -  : _node(name), _cached(false), _depth(depth) { +FSDirectory::FSDirectory(const String &prefix, const String &name, int depth, bool flat) +  : _node(name), _cached(false), _depth(depth), _flat(flat) {  	setPrefix(prefix);  } @@ -248,11 +248,11 @@ SeekableReadStream *FSDirectory::createReadStreamForMember(const String &name) c  	return stream;  } -FSDirectory *FSDirectory::getSubDirectory(const String &name, int depth) { -	return getSubDirectory(String::emptyString, name, depth); +FSDirectory *FSDirectory::getSubDirectory(const String &name, int depth, bool flat) { +	return getSubDirectory(String::emptyString, name, depth, flat);  } -FSDirectory *FSDirectory::getSubDirectory(const String &prefix, const String &name, int depth) { +FSDirectory *FSDirectory::getSubDirectory(const String &prefix, const String &name, int depth, bool flat) {  	if (name.empty() || !_node.isDirectory())  		return 0; @@ -260,7 +260,7 @@ FSDirectory *FSDirectory::getSubDirectory(const String &prefix, const String &na  	if (!node)  		return 0; -	return new FSDirectory(prefix, *node, depth); +	return new FSDirectory(prefix, *node, depth, flat);  }  void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) const { @@ -280,10 +280,13 @@ void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String&  		// since the hashmap is case insensitive, we need to check for clashes when caching  		if (it->isDirectory()) { -			if (_subDirCache.contains(lowercaseName)) { +			if (!_flat && _subDirCache.contains(lowercaseName)) {  				warning("FSDirectory::cacheDirectory: name clash when building cache, ignoring sub-directory '%s'", name.c_str());  			} else { -				cacheDirectoryRecursive(*it, depth - 1, lowercaseName + "/"); +				if (_subDirCache.contains(lowercaseName)) { +					warning("FSDirectory::cacheDirectory: name clash when building subDirCache with subdirectory '%s'", name.c_str()); +				} +				cacheDirectoryRecursive(*it, depth - 1, _flat ? prefix : lowercaseName + "/");  				_subDirCache[lowercaseName] = *it;  			}  		} else { | 
