diff options
author | Max Horn | 2007-10-04 08:04:18 +0000 |
---|---|---|
committer | Max Horn | 2007-10-04 08:04:18 +0000 |
commit | 51f082dcde8c6f1b5036f81ae7b504bcc291bced (patch) | |
tree | cf55068fb49a8c9cbe2bd26d9af2ed71be7c571f /common/fs.cpp | |
parent | 9e8167b10ce21d8286bcdd39a2de30f0da6d3aee (diff) | |
download | scummvm-rg350-51f082dcde8c6f1b5036f81ae7b504bcc291bced.tar.gz scummvm-rg350-51f082dcde8c6f1b5036f81ae7b504bcc291bced.tar.bz2 scummvm-rg350-51f082dcde8c6f1b5036f81ae7b504bcc291bced.zip |
Patch #1805208: move matchString to Common::Util
svn-id: r29154
Diffstat (limited to 'common/fs.cpp')
-rw-r--r-- | common/fs.cpp | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/common/fs.cpp b/common/fs.cpp index 7d7aa363fc..100f6c86bd 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -26,43 +26,6 @@ #include "backends/fs/abstract-fs.h" #include "backends/fs/abstract-fs-factory.h" -/** - * Simple DOS-style pattern matching function (understands * and ? like used in DOS). - * Taken from exult/files/listfiles.cc - */ -static bool matchString(const char *str, const char *pat) { - const char *p = 0; - const char *q = 0; - - for (;;) { - switch (*pat) { - case '*': - p = ++pat; - q = str; - break; - - default: - if (*pat != *str) { - if (p) { - pat = p; - str = ++q; - if (!*str) - return !*pat; - break; - } - else - return false; - } - // fallthrough - case '?': - if (!*str) - return !*pat; - pat++; - str++; - } - } -} - FilesystemNode::FilesystemNode() { _realNode = 0; _refCount = 0; @@ -233,25 +196,19 @@ bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::St return ((matches > 0) ? true : false); } -// HACK HACK HACK -extern const char *lastPathComponent(const Common::String &str); - int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const { FSList entries; FSList children; int matches = 0; dir.getChildren(entries, FilesystemNode::kListAll, hidden); - + //Breadth search (entries in the same level) for (FSList::iterator entry = entries.begin(); entry != entries.end(); ++entry) { if (entry->isDirectory()) { children.push_back(*entry); } else { - //TODO: here we assume all backends implement the lastPathComponent method. It is currently static, - // so it might be a good idea to include it inside the backend class. This would enforce its - // implementation by all ports. - if (matchString(lastPathComponent(entry->getPath()), filename.c_str())) { + if (Common::matchString(entry->getName().c_str(), filename.c_str())) { results.push_back(*entry); matches++; |