[Scummvm-cvs-logs] SF.net SVN: scummvm:[34359] scummvm/trunk/common
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Fri Sep 5 20:24:42 CEST 2008
Revision: 34359
http://scummvm.svn.sourceforge.net/scummvm/?rev=34359&view=rev
Author: peres001
Date: 2008-09-05 18:24:41 +0000 (Fri, 05 Sep 2008)
Log Message:
-----------
* Implemented a default matchPattern for Archive subclasses (courtesy of Fingolfin).
* Fixed bug in FSDirectory::matchPattern.
Modified Paths:
--------------
scummvm/trunk/common/archive.cpp
scummvm/trunk/common/archive.h
Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp 2008-09-05 17:35:00 UTC (rev 34358)
+++ scummvm/trunk/common/archive.cpp 2008-09-05 18:24:41 UTC (rev 34359)
@@ -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 @@
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 @@
return 0;
}
-
} // namespace Common
Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h 2008-09-05 17:35:00 UTC (rev 34358)
+++ scummvm/trunk/common/archive.h 2008-09-05 18:24:41 UTC (rev 34359)
@@ -62,7 +62,7 @@
*
* @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 @@
};
-
/**
* 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list