index: add skippedPathsFnmPathname variable to enable disabling the use of FNM_PATHNAME while matching in skippedPaths. Closes issue #67

This commit is contained in:
Jean-Francois Dockes
2011-11-30 16:36:51 +01:00
parent 2afc769c38
commit 3759c0b52d
8 changed files with 70 additions and 32 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ $(BIGLIB): force
cd $(depth)/lib;$(MAKE)
force:
FSTREEWALK_OBJS= trfstreewalk.o fstreewalk.o $(BIGLIB)
FSTREEWALK_OBJS= trfstreewalk.o $(BIGLIB)
trfstreewalk : $(FSTREEWALK_OBJS)
$(CXX) -o trfstreewalk $(FSTREEWALK_OBJS) $(LIBICONV) \
$(LIBSYS)
+1 -1
View File
@@ -1301,7 +1301,7 @@ int main(int argc, char **argv)
exit(1);
}
string udi;
make_udi(fn, cstr_null, udi);
make_udi(fn, "", udi);
sprintf(dic, "#whatever...\nmimetype = text/plain\nudi=%s\n",
udi.c_str());
string sdic;
+12 -2
View File
@@ -40,6 +40,8 @@
using namespace std;
#endif /* NO_NAMESPACES */
bool FsTreeWalker::o_useFnmPathname = true;
const int FsTreeWalker::FtwTravMask = FtwTravNatural|
FtwTravBreadth|FtwTravFilesThenDirs|FtwTravBreadthThenDepth;
@@ -153,7 +155,7 @@ bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
}
bool FsTreeWalker::inSkippedPaths(const string& path, bool ckparents)
{
int fnmflags = FNM_PATHNAME;
int fnmflags = o_useFnmPathname ? FNM_PATHNAME : 0;
#ifdef FNM_LEADING_DIR
if (ckparents)
fnmflags |= FNM_LEADING_DIR;
@@ -420,6 +422,8 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
#include <iostream>
#include "rclinit.h"
#include "rclconfig.h"
#include "fstreewalk.h"
using namespace std;
@@ -542,7 +546,13 @@ int main(int argc, const char **argv)
opt |= FsTreeWalker::FtwTravFilesThenDirs;
else if (op_flags & OPT_m)
opt |= FsTreeWalker::FtwTravBreadthThenDepth;
string reason;
if (!recollinit(0, 0, reason)) {
fprintf(stderr, "Init failed: %s\n", reason.c_str());
exit(1);
}
FsTreeWalker walker(opt);
walker.setSkippedNames(patterns);
walker.setSkippedPaths(paths);
+12
View File
@@ -38,6 +38,18 @@ struct stat;
*/
class FsTreeWalker {
public:
// Global option to use FNM_PATHNAME when matching paths (for
// skippedPaths).
// We initially used FNM_PATHNAME, and we can't change it now
// (because of all the config files around). So add global option
// to not use the flag, which can be set from rclconfig by adding
// a value to the config file (skippedPathsNoFnmPathname)
static bool o_useFnmPathname;
static void setNoFnmPathname()
{
o_useFnmPathname = false;
}
// Flags for call to processone(). FtwDirEnter is used when
// entering a directory. FtwDirReturn is used when returning to it
// after processing a subdirectory.