aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNicola Mettifogo2008-09-05 18:24:41 +0000
committerNicola Mettifogo2008-09-05 18:24:41 +0000
commit87d67be832d1fe3288033604d2cf391bef3af5cf (patch)
tree96a3ea1928333a576a26b303356e3732f923f912 /common
parent0ae32fe32c5eee7d1042449a0c632d77be083b0c (diff)
downloadscummvm-rg350-87d67be832d1fe3288033604d2cf391bef3af5cf.tar.gz
scummvm-rg350-87d67be832d1fe3288033604d2cf391bef3af5cf.tar.bz2
scummvm-rg350-87d67be832d1fe3288033604d2cf391bef3af5cf.zip
* Implemented a default matchPattern for Archive subclasses (courtesy of Fingolfin).
* Fixed bug in FSDirectory::matchPattern. svn-id: r34359
Diffstat (limited to 'common')
-rw-r--r--common/archive.cpp28
-rw-r--r--common/archive.h3
2 files changed, 26 insertions, 5 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index bdea62b895..18c918f914 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -25,12 +25,34 @@
#include "common/archive.h"
#include "common/fs.h"
-#include "common/file.h"
#include "common/util.h"
namespace Common {
+int Archive::matchPattern(StringList &list, const String &pattern) {
+ // Get all "names" (TODO: "files" ?)
+ StringList allNames;
+ getAllNames(allNames);
+
+ int matches = 0;
+
+ // need to match lowercase key
+ String lowercasePattern = pattern;
+ lowercasePattern.toLowercase();
+
+ StringList::iterator it = allNames.begin();
+ for ( ; it != allNames.end(); it++) {
+ if (matchString(it->c_str(), lowercasePattern.c_str())) {
+ list.push_back(*it);
+ matches++;
+ }
+ }
+
+ return matches;
+}
+
+
FSDirectory::FSDirectory(const FilesystemNode &node, int depth)
: _node(node), _cached(false), _depth(depth) {
}
@@ -158,7 +180,8 @@ int FSDirectory::matchPattern(StringList &list, const String &pattern) {
NodeCache::iterator it = _fileCache.begin();
for ( ; it != _fileCache.end(); it++) {
if (matchString((*it)._key.c_str(), lowercasePattern.c_str())) {
- list.push_back((*it)._key.c_str());
+ list.push_back((*it)._key);
+ matches++;
}
}
@@ -283,5 +306,4 @@ SeekableReadStream *SearchSet::openFile(const String &name) {
return 0;
}
-
} // namespace Common
diff --git a/common/archive.h b/common/archive.h
index 97eaf801a7..1523eef651 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -62,7 +62,7 @@ public:
*
* @return The number of names added to list.
*/
- virtual int matchPattern(StringList &list, const String &pattern) = 0;
+ virtual int matchPattern(StringList &list, const String &pattern);
/**
* Add all the names present in the Archive. Returned
@@ -144,7 +144,6 @@ public:
};
-
/**
* SearchSet enables access to a group of Archives through the Archive interface.
* Its intended usage is a situation in which there are no name clashes among names in the