rationalized how we recompute things on setkeydir. recoll_noindex and skippedNames can now be changed at any point in the tree

This commit is contained in:
dockes
2009-11-15 08:38:43 +00:00
parent 1406bca35b
commit 0ccf8fccd9
8 changed files with 225 additions and 175 deletions
+8 -5
View File
@@ -94,8 +94,6 @@ bool FsTreeWalker::addSkippedName(const string& pattern)
bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
{
data->skippedNames = patterns;
data->skippedNames.sort();
data->skippedNames.unique();
return true;
}
bool FsTreeWalker::inSkippedNames(const string& name)
@@ -125,8 +123,6 @@ bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
it != data->skippedPaths.end(); it++)
if (!(data->options & FtwNoCanon))
*it = path_canon(*it);
data->skippedPaths.sort();
data->skippedPaths.unique();
return true;
}
bool FsTreeWalker::inSkippedPaths(const string& path)
@@ -134,7 +130,14 @@ bool FsTreeWalker::inSkippedPaths(const string& path)
list<string>::const_iterator it;
for (it = data->skippedPaths.begin();
it != data->skippedPaths.end(); it++) {
if (fnmatch(it->c_str(), path.c_str(), FNM_PATHNAME) == 0)
// If we find a system where FNM_LEADING_DIR is undefined (its
// unposixy), will have to do this for all ascendant paths up
// to the topdir. We'll then have a constructor option because
// this is only useful when called externally. When used
// internally, we don't descend in skipped paths, and so don't
// need FNM_LEADING_DIR
if (fnmatch(it->c_str(), path.c_str(), FNM_PATHNAME |
FNM_LEADING_DIR) == 0)
return true;
}
return false;
+3
View File
@@ -79,8 +79,11 @@ class FsTreeWalker {
/** Set the ignored paths list */
bool setSkippedPaths(const list<string> &pathlist);
/** Test if path/name should be skipped. This can be used independantly of
* an actual tree walk */
bool inSkippedPaths(const string& path);
bool inSkippedNames(const string& name);
private:
Status iwalk(const string &dir, struct stat *stp, FsTreeWalkerCB& cb);
class Internal;
+47 -43
View File
@@ -182,71 +182,71 @@ template <class T> bool stringToStrings(const string &s, T &tokens)
states state = SPACE;
for (unsigned int i = 0; i < s.length(); i++) {
switch (s[i]) {
case '"':
case '"':
switch(state) {
case SPACE:
case SPACE:
state=INQUOTE; continue;
case TOKEN:
case TOKEN:
current += '"';
continue;
case INQUOTE:
tokens.push_back(current);
case INQUOTE:
tokens.insert(tokens.end(), current);
current.clear();
state = SPACE;
continue;
case ESCAPE:
case ESCAPE:
current += '"';
state = INQUOTE;
continue;
continue;
}
break;
case '\\':
case '\\':
switch(state) {
case SPACE:
case TOKEN:
current += '\\';
state=TOKEN;
continue;
case INQUOTE:
state = ESCAPE;
continue;
case ESCAPE:
current += '\\';
state = INQUOTE;
continue;
case SPACE:
case TOKEN:
current += '\\';
state=TOKEN;
continue;
case INQUOTE:
state = ESCAPE;
continue;
case ESCAPE:
current += '\\';
state = INQUOTE;
continue;
}
break;
case ' ':
case '\t':
case '\n':
case '\r':
case ' ':
case '\t':
case '\n':
case '\r':
switch(state) {
case SPACE:
continue;
case TOKEN:
tokens.push_back(current);
case SPACE:
continue;
case TOKEN:
tokens.insert(tokens.end(), current);
current.clear();
state = SPACE;
continue;
case INQUOTE:
case ESCAPE:
current += s[i];
continue;
case INQUOTE:
case ESCAPE:
current += s[i];
continue;
}
break;
default:
default:
switch(state) {
case ESCAPE:
state = INQUOTE;
break;
case SPACE:
state = TOKEN;
break;
case TOKEN:
case INQUOTE:
break;
case ESCAPE:
state = INQUOTE;
break;
case SPACE:
state = TOKEN;
break;
case TOKEN:
case INQUOTE:
break;
}
current += s[i];
}
@@ -255,7 +255,7 @@ template <class T> bool stringToStrings(const string &s, T &tokens)
case SPACE:
break;
case TOKEN:
tokens.push_back(current);
tokens.insert(tokens.end(), current);
break;
case INQUOTE:
case ESCAPE:
@@ -271,6 +271,10 @@ bool stringToStrings(const string &s, vector<string> &tokens)
{
return stringToStrings<vector<string> >(s, tokens);
}
bool stringToStrings(const string &s, set<string> &tokens)
{
return stringToStrings<set<string> >(s, tokens);
}
template <class T> void stringsToString(const T &tokens, string &s)
{
+1
View File
@@ -54,6 +54,7 @@ extern bool samecharset(const string &cs1, const string &cs2);
*/
extern bool stringToStrings(const string &s, list<string> &tokens);
extern bool stringToStrings(const string &s, vector<string> &tokens);
extern bool stringToStrings(const string &s, set<string> &tokens);
/**
* Inverse operation: