Got rid of Common::File::addDefaultDirectory, instead implemented the solution proposed in "Case agnostic handling for directories (and files)" on -devel.
svn-id: r44266
This commit is contained in:
parent
75113ad5f3
commit
c50940bbf4
13 changed files with 136 additions and 81 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue