COMMON: Make more members of Archive constant.
This commit is contained in:
parent
77959acd51
commit
a6ec4f70da
16 changed files with 96 additions and 96 deletions
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
GenericArchiveMember::GenericArchiveMember(String name, Archive *parent)
|
GenericArchiveMember::GenericArchiveMember(const String &name, const Archive *parent)
|
||||||
: _parent(parent), _name(name) {
|
: _parent(parent), _name(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ SeekableReadStream *GenericArchiveMember::createReadStream() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern) {
|
int Archive::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
||||||
// Get all "names" (TODO: "files" ?)
|
// Get all "names" (TODO: "files" ?)
|
||||||
ArchiveMemberList allNames;
|
ArchiveMemberList allNames;
|
||||||
listMembers(allNames);
|
listMembers(allNames);
|
||||||
|
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArchiveMemberList::iterator it = allNames.begin();
|
ArchiveMemberList::const_iterator it = allNames.begin();
|
||||||
for ( ; it != allNames.end(); ++it) {
|
for ( ; it != allNames.end(); ++it) {
|
||||||
// TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
|
// TODO: We match case-insenstivie for now, our API does not define whether that's ok or not though...
|
||||||
// For our use case case-insensitive is probably what we want to have though.
|
// For our use case case-insensitive is probably what we want to have though.
|
||||||
|
@ -206,11 +206,11 @@ void SearchSet::setPriority(const String &name, int priority) {
|
||||||
insert(node);
|
insert(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SearchSet::hasFile(const String &name) {
|
bool SearchSet::hasFile(const String &name) const {
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ArchiveNodeList::iterator it = _list.begin();
|
ArchiveNodeList::const_iterator it = _list.begin();
|
||||||
for ( ; it != _list.end(); ++it) {
|
for ( ; it != _list.end(); ++it) {
|
||||||
if (it->_arc->hasFile(name))
|
if (it->_arc->hasFile(name))
|
||||||
return true;
|
return true;
|
||||||
|
@ -219,31 +219,31 @@ bool SearchSet::hasFile(const String &name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) {
|
int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArchiveNodeList::iterator it = _list.begin();
|
ArchiveNodeList::const_iterator it = _list.begin();
|
||||||
for ( ; it != _list.end(); ++it)
|
for ( ; it != _list.end(); ++it)
|
||||||
matches += it->_arc->listMatchingMembers(list, pattern);
|
matches += it->_arc->listMatchingMembers(list, pattern);
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SearchSet::listMembers(ArchiveMemberList &list) {
|
int SearchSet::listMembers(ArchiveMemberList &list) const {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArchiveNodeList::iterator it = _list.begin();
|
ArchiveNodeList::const_iterator it = _list.begin();
|
||||||
for ( ; it != _list.end(); ++it)
|
for ( ; it != _list.end(); ++it)
|
||||||
matches += it->_arc->listMembers(list);
|
matches += it->_arc->listMembers(list);
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveMemberPtr SearchSet::getMember(const String &name) {
|
const ArchiveMemberPtr SearchSet::getMember(const String &name) const {
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
return ArchiveMemberPtr();
|
return ArchiveMemberPtr();
|
||||||
|
|
||||||
ArchiveNodeList::iterator it = _list.begin();
|
ArchiveNodeList::const_iterator it = _list.begin();
|
||||||
for ( ; it != _list.end(); ++it) {
|
for ( ; it != _list.end(); ++it) {
|
||||||
if (it->_arc->hasFile(name))
|
if (it->_arc->hasFile(name))
|
||||||
return it->_arc->getMember(name);
|
return it->_arc->getMember(name);
|
||||||
|
|
|
@ -65,10 +65,10 @@ class Archive;
|
||||||
* is destroyed.
|
* is destroyed.
|
||||||
*/
|
*/
|
||||||
class GenericArchiveMember : public ArchiveMember {
|
class GenericArchiveMember : public ArchiveMember {
|
||||||
Archive *_parent;
|
const Archive *_parent;
|
||||||
String _name;
|
const String _name;
|
||||||
public:
|
public:
|
||||||
GenericArchiveMember(String name, Archive *parent);
|
GenericArchiveMember(const String &name, const Archive *parent);
|
||||||
String getName() const;
|
String getName() const;
|
||||||
SeekableReadStream *createReadStream() const;
|
SeekableReadStream *createReadStream() const;
|
||||||
};
|
};
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
* Patterns are not allowed, as this is meant to be a quick File::exists()
|
* Patterns are not allowed, as this is meant to be a quick File::exists()
|
||||||
* replacement.
|
* replacement.
|
||||||
*/
|
*/
|
||||||
virtual bool hasFile(const String &name) = 0;
|
virtual bool hasFile(const String &name) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all members of the Archive matching the specified pattern to list.
|
* Add all members of the Archive matching the specified pattern to list.
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return the number of members added to list
|
* @return the number of members added to list
|
||||||
*/
|
*/
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern);
|
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all members of the Archive to list.
|
* Add all members of the Archive to list.
|
||||||
|
@ -104,12 +104,12 @@ public:
|
||||||
*
|
*
|
||||||
* @return the number of names added to list
|
* @return the number of names added to list
|
||||||
*/
|
*/
|
||||||
virtual int listMembers(ArchiveMemberList &list) = 0;
|
virtual int listMembers(ArchiveMemberList &list) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a ArchiveMember representation of the given file.
|
* Returns a ArchiveMember representation of the given file.
|
||||||
*/
|
*/
|
||||||
virtual ArchiveMemberPtr getMember(const String &name) = 0;
|
virtual const ArchiveMemberPtr getMember(const String &name) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a stream bound to a member with the specified name in the
|
* Create a stream bound to a member with the specified name in the
|
||||||
|
@ -230,11 +230,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setPriority(const String& name, int priority);
|
void setPriority(const String& name, int priority);
|
||||||
|
|
||||||
virtual bool hasFile(const String &name);
|
virtual bool hasFile(const String &name) const;
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern);
|
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
||||||
virtual int listMembers(ArchiveMemberList &list);
|
virtual int listMembers(ArchiveMemberList &list) const;
|
||||||
|
|
||||||
virtual ArchiveMemberPtr getMember(const String &name);
|
virtual const ArchiveMemberPtr getMember(const String &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements createReadStreamForMember from Archive base class. The current policy is
|
* Implements createReadStreamForMember from Archive base class. The current policy is
|
||||||
|
|
|
@ -197,7 +197,7 @@ FSNode *FSDirectory::lookupCache(NodeCache &cache, const String &name) const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FSDirectory::hasFile(const String &name) {
|
bool FSDirectory::hasFile(const String &name) const {
|
||||||
if (name.empty() || !_node.isDirectory())
|
if (name.empty() || !_node.isDirectory())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ bool FSDirectory::hasFile(const String &name) {
|
||||||
return node && node->exists();
|
return node && node->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveMemberPtr FSDirectory::getMember(const String &name) {
|
const ArchiveMemberPtr FSDirectory::getMember(const String &name) const {
|
||||||
if (name.empty() || !_node.isDirectory())
|
if (name.empty() || !_node.isDirectory())
|
||||||
return ArchiveMemberPtr();
|
return ArchiveMemberPtr();
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ void FSDirectory::ensureCached() const {
|
||||||
_cached = true;
|
_cached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) {
|
int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
|
||||||
if (!_node.isDirectory())
|
if (!_node.isDirectory())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
|
||||||
lowercasePattern.toLowercase();
|
lowercasePattern.toLowercase();
|
||||||
|
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
NodeCache::iterator it = _fileCache.begin();
|
NodeCache::const_iterator it = _fileCache.begin();
|
||||||
for ( ; it != _fileCache.end(); ++it) {
|
for ( ; it != _fileCache.end(); ++it) {
|
||||||
if (it->_key.matchString(lowercasePattern, false, true)) {
|
if (it->_key.matchString(lowercasePattern, false, true)) {
|
||||||
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
|
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
|
||||||
|
@ -318,7 +318,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSDirectory::listMembers(ArchiveMemberList &list) {
|
int FSDirectory::listMembers(ArchiveMemberList &list) const {
|
||||||
if (!_node.isDirectory())
|
if (!_node.isDirectory())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ int FSDirectory::listMembers(ArchiveMemberList &list) {
|
||||||
ensureCached();
|
ensureCached();
|
||||||
|
|
||||||
int files = 0;
|
int files = 0;
|
||||||
for (NodeCache::iterator it = _fileCache.begin(); it != _fileCache.end(); ++it) {
|
for (NodeCache::const_iterator it = _fileCache.begin(); it != _fileCache.end(); ++it) {
|
||||||
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
|
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
|
||||||
++files;
|
++files;
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,23 +318,23 @@ public:
|
||||||
* Checks for existence in the cache. A full match of relative path and filename is needed
|
* Checks for existence in the cache. A full match of relative path and filename is needed
|
||||||
* for success.
|
* for success.
|
||||||
*/
|
*/
|
||||||
virtual bool hasFile(const String &name);
|
virtual bool hasFile(const String &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of matching file names. Pattern can use GLOB wildcards.
|
* Returns a list of matching file names. Pattern can use GLOB wildcards.
|
||||||
*/
|
*/
|
||||||
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern);
|
virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all the files in the cache.
|
* Returns a list of all the files in the cache.
|
||||||
*/
|
*/
|
||||||
virtual int listMembers(ArchiveMemberList &list);
|
virtual int listMembers(ArchiveMemberList &list) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a ArchiveMember representation of the specified file. A full match of relative
|
* Get a ArchiveMember representation of the specified file. A full match of relative
|
||||||
* path and filename is needed for success.
|
* path and filename is needed for success.
|
||||||
*/
|
*/
|
||||||
virtual ArchiveMemberPtr getMember(const String &name);
|
virtual const ArchiveMemberPtr getMember(const String &name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the specified file. A full match of relative path and filename is needed
|
* Open the specified file. A full match of relative path and filename is needed
|
||||||
|
|
|
@ -701,9 +701,9 @@ public:
|
||||||
virtual ~ArjArchive();
|
virtual ~ArjArchive();
|
||||||
|
|
||||||
// Archive implementation
|
// Archive implementation
|
||||||
virtual bool hasFile(const String &name);
|
virtual bool hasFile(const String &name) const;
|
||||||
virtual int listMembers(ArchiveMemberList &list);
|
virtual int listMembers(ArchiveMemberList &list) const;
|
||||||
virtual ArchiveMemberPtr getMember(const String &name);
|
virtual const ArchiveMemberPtr getMember(const String &name) const;
|
||||||
virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
|
virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -745,14 +745,14 @@ ArjArchive::~ArjArchive() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArjArchive::hasFile(const String &name) {
|
bool ArjArchive::hasFile(const String &name) const {
|
||||||
return _headers.contains(name);
|
return _headers.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ArjArchive::listMembers(ArchiveMemberList &list) {
|
int ArjArchive::listMembers(ArchiveMemberList &list) const {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
|
|
||||||
ArjHeadersMap::iterator it = _headers.begin();
|
ArjHeadersMap::const_iterator it = _headers.begin();
|
||||||
for ( ; it != _headers.end(); ++it) {
|
for ( ; it != _headers.end(); ++it) {
|
||||||
list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(it->_value->filename, this)));
|
list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(it->_value->filename, this)));
|
||||||
matches++;
|
matches++;
|
||||||
|
@ -761,7 +761,7 @@ int ArjArchive::listMembers(ArchiveMemberList &list) {
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveMemberPtr ArjArchive::getMember(const String &name) {
|
const ArchiveMemberPtr ArjArchive::getMember(const String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return ArchiveMemberPtr();
|
return ArchiveMemberPtr();
|
||||||
|
|
||||||
|
|
|
@ -1426,9 +1426,9 @@ public:
|
||||||
|
|
||||||
~ZipArchive();
|
~ZipArchive();
|
||||||
|
|
||||||
virtual bool hasFile(const String &name);
|
virtual bool hasFile(const String &name) const;
|
||||||
virtual int listMembers(ArchiveMemberList &list);
|
virtual int listMembers(ArchiveMemberList &list) const;
|
||||||
virtual ArchiveMemberPtr getMember(const String &name);
|
virtual const ArchiveMemberPtr getMember(const String &name) const;
|
||||||
virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
|
virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1458,11 +1458,11 @@ ZipArchive::~ZipArchive() {
|
||||||
unzClose(_zipFile);
|
unzClose(_zipFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZipArchive::hasFile(const String &name) {
|
bool ZipArchive::hasFile(const String &name) const {
|
||||||
return (unzLocateFile(_zipFile, name.c_str(), 2) == UNZ_OK);
|
return (unzLocateFile(_zipFile, name.c_str(), 2) == UNZ_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZipArchive::listMembers(ArchiveMemberList &list) {
|
int ZipArchive::listMembers(ArchiveMemberList &list) const {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
int err = unzGoToFirstFile(_zipFile);
|
int err = unzGoToFirstFile(_zipFile);
|
||||||
|
|
||||||
|
@ -1481,7 +1481,7 @@ int ZipArchive::listMembers(ArchiveMemberList &list) {
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveMemberPtr ZipArchive::getMember(const String &name) {
|
const ArchiveMemberPtr ZipArchive::getMember(const String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return ArchiveMemberPtr();
|
return ArchiveMemberPtr();
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ public:
|
||||||
~InstallShieldCabinet();
|
~InstallShieldCabinet();
|
||||||
|
|
||||||
// Common::Archive API implementation
|
// Common::Archive API implementation
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -161,18 +161,18 @@ InstallShieldCabinet::InstallShieldCabinet(const Common::String &filename) : _in
|
||||||
delete[] fileTableOffsets;
|
delete[] fileTableOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallShieldCabinet::hasFile(const Common::String &name) {
|
bool InstallShieldCabinet::hasFile(const Common::String &name) const {
|
||||||
return _map.contains(name);
|
return _map.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) {
|
int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
|
for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
|
||||||
list.push_back(getMember(it->_key));
|
list.push_back(getMember(it->_key));
|
||||||
|
|
||||||
return _map.size();
|
return _map.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &name) const {
|
||||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
|
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,11 @@ PlainArchive::PlainArchive(Common::ArchiveMemberPtr file)
|
||||||
: _file(file), _files() {
|
: _file(file), _files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlainArchive::hasFile(const Common::String &name) {
|
bool PlainArchive::hasFile(const Common::String &name) const {
|
||||||
return (_files.find(name) != _files.end());
|
return (_files.find(name) != _files.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlainArchive::listMembers(Common::ArchiveMemberList &list) {
|
int PlainArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||||
|
@ -52,7 +52,7 @@ int PlainArchive::listMembers(Common::ArchiveMemberList &list) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr PlainArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr PlainArchive::getMember(const Common::String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return Common::ArchiveMemberPtr();
|
return Common::ArchiveMemberPtr();
|
||||||
|
|
||||||
|
@ -92,11 +92,11 @@ TlkArchive::~TlkArchive() {
|
||||||
delete[] _fileEntries;
|
delete[] _fileEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TlkArchive::hasFile(const Common::String &name) {
|
bool TlkArchive::hasFile(const Common::String &name) const {
|
||||||
return (findFile(name) != 0);
|
return (findFile(name) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TlkArchive::listMembers(Common::ArchiveMemberList &list) {
|
int TlkArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
uint count = 0;
|
uint count = 0;
|
||||||
|
|
||||||
for (; count < _entryCount; ++count) {
|
for (; count < _entryCount; ++count) {
|
||||||
|
@ -107,7 +107,7 @@ int TlkArchive::listMembers(Common::ArchiveMemberList &list) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr TlkArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr TlkArchive::getMember(const Common::String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return Common::ArchiveMemberPtr();
|
return Common::ArchiveMemberPtr();
|
||||||
|
|
||||||
|
@ -186,11 +186,11 @@ CachedArchive::~CachedArchive() {
|
||||||
_files.clear();
|
_files.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CachedArchive::hasFile(const Common::String &name) {
|
bool CachedArchive::hasFile(const Common::String &name) const {
|
||||||
return (_files.find(name) != _files.end());
|
return (_files.find(name) != _files.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CachedArchive::listMembers(Common::ArchiveMemberList &list) {
|
int CachedArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||||
|
@ -201,7 +201,7 @@ int CachedArchive::listMembers(Common::ArchiveMemberList &list) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr CachedArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr CachedArchive::getMember(const Common::String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return Common::ArchiveMemberPtr();
|
return Common::ArchiveMemberPtr();
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ public:
|
||||||
Entry getFileEntry(const Common::String &name) const;
|
Entry getFileEntry(const Common::String &name) const;
|
||||||
|
|
||||||
// Common::Archive API implementation
|
// Common::Archive API implementation
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
private:
|
private:
|
||||||
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
|
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
|
||||||
|
@ -65,9 +65,9 @@ public:
|
||||||
TlkArchive(Common::ArchiveMemberPtr file, uint16 entryCount, const uint32 *fileEntries);
|
TlkArchive(Common::ArchiveMemberPtr file, uint16 entryCount, const uint32 *fileEntries);
|
||||||
~TlkArchive();
|
~TlkArchive();
|
||||||
|
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
private:
|
private:
|
||||||
Common::ArchiveMemberPtr _file;
|
Common::ArchiveMemberPtr _file;
|
||||||
|
@ -92,9 +92,9 @@ public:
|
||||||
CachedArchive(const FileInputList &files);
|
CachedArchive(const FileInputList &files);
|
||||||
~CachedArchive();
|
~CachedArchive();
|
||||||
|
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
private:
|
private:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
|
|
|
@ -74,11 +74,11 @@ HPFArchive::HPFArchive(const Common::String &path) {
|
||||||
delete archive;
|
delete archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HPFArchive::hasFile(const Common::String &name) {
|
bool HPFArchive::hasFile(const Common::String &name) const {
|
||||||
return (_files.find(name) != _files.end());
|
return (_files.find(name) != _files.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
int HPFArchive::listMembers(Common::ArchiveMemberList &list) {
|
int HPFArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
int numMembers = 0;
|
int numMembers = 0;
|
||||||
|
|
||||||
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
for (FileMap::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||||
|
@ -89,7 +89,7 @@ int HPFArchive::listMembers(Common::ArchiveMemberList &list) {
|
||||||
return numMembers;
|
return numMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr HPFArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr HPFArchive::getMember(const Common::String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return Common::ArchiveMemberPtr();
|
return Common::ArchiveMemberPtr();
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ class HPFArchive : public Common::Archive {
|
||||||
public:
|
public:
|
||||||
HPFArchive(const Common::String &path);
|
HPFArchive(const Common::String &path);
|
||||||
|
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
|
|
||||||
int count() { return _files.size(); }
|
int count() { return _files.size(); }
|
||||||
|
|
|
@ -148,8 +148,8 @@ Common::SeekableReadStream *ResourceManager::getFileStream(const Common::String
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Archive functions
|
// Archive functions
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool ResourceManager::hasFile(const Common::String &name) {
|
bool ResourceManager::hasFile(const Common::String &name) const {
|
||||||
for (Common::Array<HPFArchive *>::iterator it = _archives.begin(); it != _archives.end(); ++it) {
|
for (Common::Array<HPFArchive *>::const_iterator it = _archives.begin(); it != _archives.end(); ++it) {
|
||||||
if ((*it)->hasFile(name))
|
if ((*it)->hasFile(name))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,10 @@ bool ResourceManager::hasFile(const Common::String &name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResourceManager::listMembers(Common::ArchiveMemberList &list) {
|
int ResourceManager::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (Common::Array<HPFArchive *>::iterator it = _archives.begin(); it != _archives.end(); ++it) {
|
for (Common::Array<HPFArchive *>::const_iterator it = _archives.begin(); it != _archives.end(); ++it) {
|
||||||
|
|
||||||
Common::ArchiveMemberList members;
|
Common::ArchiveMemberList members;
|
||||||
count += (*it)->listMembers(members);
|
count += (*it)->listMembers(members);
|
||||||
|
@ -171,7 +171,7 @@ int ResourceManager::listMembers(Common::ArchiveMemberList &list) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr ResourceManager::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr ResourceManager::getMember(const Common::String &name) const {
|
||||||
if (!hasFile(name))
|
if (!hasFile(name))
|
||||||
return Common::ArchiveMemberPtr();
|
return Common::ArchiveMemberPtr();
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,9 @@ public:
|
||||||
Common::SeekableReadStream *getFileStream(const Common::String &name);
|
Common::SeekableReadStream *getFileStream(const Common::String &name);
|
||||||
|
|
||||||
// Archive functions
|
// Archive functions
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
|
|
||||||
// Resource loading
|
// Resource loading
|
||||||
|
|
|
@ -107,18 +107,18 @@ void InstallerArchive::close() {
|
||||||
_map.clear();
|
_map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstallerArchive::hasFile(const Common::String &name) {
|
bool InstallerArchive::hasFile(const Common::String &name) const {
|
||||||
return _map.contains(name);
|
return _map.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstallerArchive::listMembers(Common::ArchiveMemberList &list) {
|
int InstallerArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
|
for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
|
||||||
list.push_back(getMember(it->_key));
|
list.push_back(getMember(it->_key));
|
||||||
|
|
||||||
return _map.size();
|
return _map.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr InstallerArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr InstallerArchive::getMember(const Common::String &name) const {
|
||||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
|
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ public:
|
||||||
bool isOpen() const { return _stream != 0; }
|
bool isOpen() const { return _stream != 0; }
|
||||||
|
|
||||||
// Common::Archive API implementation
|
// Common::Archive API implementation
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -73,9 +73,9 @@ public:
|
||||||
~NSArchive();
|
~NSArchive();
|
||||||
|
|
||||||
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||||
bool hasFile(const Common::String &name);
|
bool hasFile(const Common::String &name) const;
|
||||||
int listMembers(Common::ArchiveMemberList &list);
|
int listMembers(Common::ArchiveMemberList &list) const;
|
||||||
Common::ArchiveMemberPtr getMember(const Common::String &name);
|
const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,23 +137,23 @@ Common::SeekableReadStream *NSArchive::createReadStreamForMember(const Common::S
|
||||||
return new Common::SeekableSubReadStream(_stream, offset, endOffset, DisposeAfterUse::NO);
|
return new Common::SeekableSubReadStream(_stream, offset, endOffset, DisposeAfterUse::NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NSArchive::hasFile(const Common::String &name) {
|
bool NSArchive::hasFile(const Common::String &name) const {
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
return false;
|
return false;
|
||||||
return lookup(name.c_str()) != _numFiles;
|
return lookup(name.c_str()) != _numFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NSArchive::listMembers(Common::ArchiveMemberList &list) {
|
int NSArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||||
for (uint32 i = 0; i < _numFiles; i++) {
|
for (uint32 i = 0; i < _numFiles; i++) {
|
||||||
list.push_back(Common::SharedPtr<Common::GenericArchiveMember>(new Common::GenericArchiveMember(_archiveDir[i], this)));
|
list.push_back(Common::SharedPtr<Common::GenericArchiveMember>(new Common::GenericArchiveMember(_archiveDir[i], this)));
|
||||||
}
|
}
|
||||||
return _numFiles;
|
return _numFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ArchiveMemberPtr NSArchive::getMember(const Common::String &name) {
|
const Common::ArchiveMemberPtr NSArchive::getMember(const Common::String &name) const {
|
||||||
uint32 index = lookup(name.c_str());
|
uint32 index = lookup(name.c_str());
|
||||||
|
|
||||||
char *item = 0;
|
const char *item = 0;
|
||||||
if (index < _numFiles) {
|
if (index < _numFiles) {
|
||||||
item = _archiveDir[index];
|
item = _archiveDir[index];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue