aboutsummaryrefslogtreecommitdiff
path: root/common/archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/archive.cpp')
-rw-r--r--common/archive.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index ecc00f4cff..e815b781bf 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -123,6 +123,52 @@ void SearchSet::addDirectory(const String &name, const FSNode &dir, int priority
add(name, new FSDirectory(dir, depth, flat), priority);
}
+void SearchSet::addSubDirectoriesMatching(const FSNode &directory, String pattern, bool ignoreCase, int priority) {
+ FSList subDirs;
+ if (!directory.getChildren(subDirs))
+ return;
+
+ String nextPattern;
+ String::const_iterator sep = Common::find(pattern.begin(), pattern.end(), '/');
+ if (sep != pattern.end()) {
+ pattern = String(pattern.begin(), sep);
+
+ ++sep;
+ if (sep != pattern.end())
+ nextPattern = String(sep, pattern.end());
+ }
+
+ // TODO: The code we have for displaying all matches, which vary only in case, might
+ // be a bit overhead, but as long as we want to display all useful information to the
+ // user we will need to keep track of all directory names added so far. We might
+ // want to reconsider this though.
+ typedef HashMap<String, bool, IgnoreCase_Hash, IgnoreCase_EqualTo> MatchList;
+ MatchList multipleMatches;
+ MatchList::iterator matchIter;
+
+ for (FSList::const_iterator i = subDirs.begin(); i != subDirs.end(); ++i) {
+ String name = i->getName();
+
+ if (Common::matchString(name.c_str(), pattern.c_str(), ignoreCase)) {
+ matchIter = multipleMatches.find(name);
+ if (matchIter == multipleMatches.end()) {
+ multipleMatches[name] = true;
+ } else {
+ if (matchIter->_value) {
+ warning("Clash in case for match of pattern \"%s\" found in directory \"%s\": \"%s\"", pattern.c_str(), directory.getPath().c_str(), matchIter->_key.c_str());
+ matchIter->_value = false;
+ }
+
+ warning("Clash in case for match of pattern \"%s\" found in directory \"%s\": \"%s\"", pattern.c_str(), directory.getPath().c_str(), name.c_str());
+ }
+
+ if (nextPattern.empty())
+ addDirectory(name, *i, priority);
+ else
+ addSubDirectoriesMatching(*i, nextPattern, ignoreCase, priority);
+ }
+ }
+}
void SearchSet::remove(const String &name) {
ArchiveNodeList::iterator it = find(name);