aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAndrea Corna2011-12-13 17:20:25 +0100
committerJohannes Schickel2011-12-13 17:55:57 +0100
commita6ec4f70da120a1ce406ed4dd9e149e081542f59 (patch)
tree36d09611f523974f570318e6e579b89b30e886a9 /common
parent77959acd51982d9fedec94ac07241b1702681c6a (diff)
downloadscummvm-rg350-a6ec4f70da120a1ce406ed4dd9e149e081542f59.tar.gz
scummvm-rg350-a6ec4f70da120a1ce406ed4dd9e149e081542f59.tar.bz2
scummvm-rg350-a6ec4f70da120a1ce406ed4dd9e149e081542f59.zip
COMMON: Make more members of Archive constant.
Diffstat (limited to 'common')
-rw-r--r--common/archive.cpp22
-rw-r--r--common/archive.h22
-rw-r--r--common/fs.cpp12
-rw-r--r--common/fs.h8
-rw-r--r--common/unarj.cpp14
-rw-r--r--common/unzip.cpp12
6 files changed, 45 insertions, 45 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index 954de8bcaa..1323f14805 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -27,7 +27,7 @@
namespace Common {
-GenericArchiveMember::GenericArchiveMember(String name, Archive *parent)
+GenericArchiveMember::GenericArchiveMember(const String &name, const Archive *parent)
: _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" ?)
ArchiveMemberList allNames;
listMembers(allNames);
int matches = 0;
- ArchiveMemberList::iterator it = allNames.begin();
+ ArchiveMemberList::const_iterator it = allNames.begin();
for ( ; it != allNames.end(); ++it) {
// 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.
@@ -206,11 +206,11 @@ void SearchSet::setPriority(const String &name, int priority) {
insert(node);
}
-bool SearchSet::hasFile(const String &name) {
+bool SearchSet::hasFile(const String &name) const {
if (name.empty())
return false;
- ArchiveNodeList::iterator it = _list.begin();
+ ArchiveNodeList::const_iterator it = _list.begin();
for ( ; it != _list.end(); ++it) {
if (it->_arc->hasFile(name))
return true;
@@ -219,31 +219,31 @@ bool SearchSet::hasFile(const String &name) {
return false;
}
-int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) {
+int SearchSet::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
int matches = 0;
- ArchiveNodeList::iterator it = _list.begin();
+ ArchiveNodeList::const_iterator it = _list.begin();
for ( ; it != _list.end(); ++it)
matches += it->_arc->listMatchingMembers(list, pattern);
return matches;
}
-int SearchSet::listMembers(ArchiveMemberList &list) {
+int SearchSet::listMembers(ArchiveMemberList &list) const {
int matches = 0;
- ArchiveNodeList::iterator it = _list.begin();
+ ArchiveNodeList::const_iterator it = _list.begin();
for ( ; it != _list.end(); ++it)
matches += it->_arc->listMembers(list);
return matches;
}
-ArchiveMemberPtr SearchSet::getMember(const String &name) {
+const ArchiveMemberPtr SearchSet::getMember(const String &name) const {
if (name.empty())
return ArchiveMemberPtr();
- ArchiveNodeList::iterator it = _list.begin();
+ ArchiveNodeList::const_iterator it = _list.begin();
for ( ; it != _list.end(); ++it) {
if (it->_arc->hasFile(name))
return it->_arc->getMember(name);
diff --git a/common/archive.h b/common/archive.h
index c8e78f9bc8..ffd86d786d 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -65,10 +65,10 @@ class Archive;
* is destroyed.
*/
class GenericArchiveMember : public ArchiveMember {
- Archive *_parent;
- String _name;
+ const Archive *_parent;
+ const String _name;
public:
- GenericArchiveMember(String name, Archive *parent);
+ GenericArchiveMember(const String &name, const Archive *parent);
String getName() const;
SeekableReadStream *createReadStream() const;
};
@@ -88,7 +88,7 @@ public:
* Patterns are not allowed, as this is meant to be a quick File::exists()
* 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.
@@ -96,7 +96,7 @@ public:
*
* @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.
@@ -104,12 +104,12 @@ public:
*
* @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.
*/
- 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
@@ -230,11 +230,11 @@ public:
*/
void setPriority(const String& name, int priority);
- virtual bool hasFile(const String &name);
- virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern);
- virtual int listMembers(ArchiveMemberList &list);
+ virtual bool hasFile(const String &name) const;
+ virtual int listMatchingMembers(ArchiveMemberList &list, const String &pattern) const;
+ 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
diff --git a/common/fs.cpp b/common/fs.cpp
index 4b56cc4594..8ea96e458a 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -197,7 +197,7 @@ FSNode *FSDirectory::lookupCache(NodeCache &cache, const String &name) const {
return 0;
}
-bool FSDirectory::hasFile(const String &name) {
+bool FSDirectory::hasFile(const String &name) const {
if (name.empty() || !_node.isDirectory())
return false;
@@ -205,7 +205,7 @@ bool FSDirectory::hasFile(const String &name) {
return node && node->exists();
}
-ArchiveMemberPtr FSDirectory::getMember(const String &name) {
+const ArchiveMemberPtr FSDirectory::getMember(const String &name) const {
if (name.empty() || !_node.isDirectory())
return ArchiveMemberPtr();
@@ -295,7 +295,7 @@ void FSDirectory::ensureCached() const {
_cached = true;
}
-int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) {
+int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &pattern) const {
if (!_node.isDirectory())
return 0;
@@ -308,7 +308,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
lowercasePattern.toLowercase();
int matches = 0;
- NodeCache::iterator it = _fileCache.begin();
+ NodeCache::const_iterator it = _fileCache.begin();
for ( ; it != _fileCache.end(); ++it) {
if (it->_key.matchString(lowercasePattern, false, true)) {
list.push_back(ArchiveMemberPtr(new FSNode(it->_value)));
@@ -318,7 +318,7 @@ int FSDirectory::listMatchingMembers(ArchiveMemberList &list, const String &patt
return matches;
}
-int FSDirectory::listMembers(ArchiveMemberList &list) {
+int FSDirectory::listMembers(ArchiveMemberList &list) const {
if (!_node.isDirectory())
return 0;
@@ -326,7 +326,7 @@ int FSDirectory::listMembers(ArchiveMemberList &list) {
ensureCached();
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)));
++files;
}
diff --git a/common/fs.h b/common/fs.h
index aeaa14718e..fadd672bb1 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -318,23 +318,23 @@ public:
* Checks for existence in the cache. A full match of relative path and filename is needed
* 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.
*/
- 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.
*/
- virtual int listMembers(ArchiveMemberList &list);
+ virtual int listMembers(ArchiveMemberList &list) const;
/**
* Get a ArchiveMember representation of the specified file. A full match of relative
* 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
diff --git a/common/unarj.cpp b/common/unarj.cpp
index cccc330bb5..fe3c17a2ac 100644
--- a/common/unarj.cpp
+++ b/common/unarj.cpp
@@ -701,9 +701,9 @@ public:
virtual ~ArjArchive();
// Archive implementation
- virtual bool hasFile(const String &name);
- virtual int listMembers(ArchiveMemberList &list);
- virtual ArchiveMemberPtr getMember(const String &name);
+ virtual bool hasFile(const String &name) const;
+ virtual int listMembers(ArchiveMemberList &list) const;
+ virtual const ArchiveMemberPtr getMember(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);
}
-int ArjArchive::listMembers(ArchiveMemberList &list) {
+int ArjArchive::listMembers(ArchiveMemberList &list) const {
int matches = 0;
- ArjHeadersMap::iterator it = _headers.begin();
+ ArjHeadersMap::const_iterator it = _headers.begin();
for ( ; it != _headers.end(); ++it) {
list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(it->_value->filename, this)));
matches++;
@@ -761,7 +761,7 @@ int ArjArchive::listMembers(ArchiveMemberList &list) {
return matches;
}
-ArchiveMemberPtr ArjArchive::getMember(const String &name) {
+const ArchiveMemberPtr ArjArchive::getMember(const String &name) const {
if (!hasFile(name))
return ArchiveMemberPtr();
diff --git a/common/unzip.cpp b/common/unzip.cpp
index 8650c91866..8061f712d4 100644
--- a/common/unzip.cpp
+++ b/common/unzip.cpp
@@ -1426,9 +1426,9 @@ public:
~ZipArchive();
- virtual bool hasFile(const String &name);
- virtual int listMembers(ArchiveMemberList &list);
- virtual ArchiveMemberPtr getMember(const String &name);
+ virtual bool hasFile(const String &name) const;
+ virtual int listMembers(ArchiveMemberList &list) const;
+ virtual const ArchiveMemberPtr getMember(const String &name) const;
virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
};
@@ -1458,11 +1458,11 @@ ZipArchive::~ZipArchive() {
unzClose(_zipFile);
}
-bool ZipArchive::hasFile(const String &name) {
+bool ZipArchive::hasFile(const String &name) const {
return (unzLocateFile(_zipFile, name.c_str(), 2) == UNZ_OK);
}
-int ZipArchive::listMembers(ArchiveMemberList &list) {
+int ZipArchive::listMembers(ArchiveMemberList &list) const {
int matches = 0;
int err = unzGoToFirstFile(_zipFile);
@@ -1481,7 +1481,7 @@ int ZipArchive::listMembers(ArchiveMemberList &list) {
return matches;
}
-ArchiveMemberPtr ZipArchive::getMember(const String &name) {
+const ArchiveMemberPtr ZipArchive::getMember(const String &name) const {
if (!hasFile(name))
return ArchiveMemberPtr();