diff options
author | Nicola Mettifogo | 2008-10-12 06:06:04 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2008-10-12 06:06:04 +0000 |
commit | fb0d112bbddc930115dcfffef5fb9f92e1d6cf7a (patch) | |
tree | d69f0cdcb9b2513e541dd04c3e6a8c12fa5934ee /common/archive.cpp | |
parent | 3d41300895447d5c55b1eaa5aa8580ead1708758 (diff) | |
download | scummvm-rg350-fb0d112bbddc930115dcfffef5fb9f92e1d6cf7a.tar.gz scummvm-rg350-fb0d112bbddc930115dcfffef5fb9f92e1d6cf7a.tar.bz2 scummvm-rg350-fb0d112bbddc930115dcfffef5fb9f92e1d6cf7a.zip |
* Added prefix support to cache entries of FSDirectory, as specified in patch #2034983.
* Updated comments on most Archive-related classes.
svn-id: r34776
Diffstat (limited to 'common/archive.cpp')
-rw-r--r-- | common/archive.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/common/archive.cpp b/common/archive.cpp index 96ead55abd..c39912bfe4 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -71,7 +71,7 @@ int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern) */ class FSDirectoryMember : public ArchiveMember { FSNode _node; - + public: FSDirectoryMember(FSNode &node) : _node(node) { } @@ -98,13 +98,33 @@ FSDirectory::FSDirectory(const FSNode &node, int depth) : _node(node), _cached(false), _depth(depth) { } +FSDirectory::FSDirectory(const String &prefix, const FSNode &node, int depth) + : _node(node), _cached(false), _depth(depth) { + + setPrefix(prefix); +} + FSDirectory::FSDirectory(const String &name, int depth) : _node(name), _cached(false), _depth(depth) { } +FSDirectory::FSDirectory(const String &prefix, const String &name, int depth) + : _node(name), _cached(false), _depth(depth) { + + setPrefix(prefix); +} + FSDirectory::~FSDirectory() { } +void FSDirectory::setPrefix(const String &prefix) { + _prefix = prefix; + + if (!_prefix.empty() && !_prefix.hasSuffix("/")) { + _prefix += "/"; + } +} + FSNode FSDirectory::getFSNode() const { return _node; } @@ -113,7 +133,7 @@ FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) { // make caching as lazy as possible if (!name.empty()) { if (!_cached) { - cacheDirectoryRecursive(_node, _depth, ""); + cacheDirectoryRecursive(_node, _depth, _prefix); _cached = true; } @@ -157,12 +177,16 @@ SeekableReadStream *FSDirectory::openFile(const String &name) { } FSDirectory *FSDirectory::getSubDirectory(const String &name, int depth) { + return getSubDirectory(String::emptyString, name, depth); +} + +FSDirectory *FSDirectory::getSubDirectory(const String &prefix, const String &name, int depth) { if (name.empty() || !_node.isDirectory()) { return 0; } FSNode node = lookupCache(_subDirCache, name); - return new FSDirectory(node, depth); + return new FSDirectory(prefix, node, depth); } void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) { |