monitor: dont add watch on created dir if in skippedXXX
This commit is contained in:
parent
acc251054e
commit
16bca7840a
@ -1,7 +1,7 @@
|
|||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
#ifdef RCL_MONITOR
|
#ifdef RCL_MONITOR
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.11 2007-05-21 13:30:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.12 2007-07-12 10:53:07 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -158,7 +158,12 @@ void *rclMonRcvRun(void *q)
|
|||||||
// timeout so that an intr will be detected
|
// timeout so that an intr will be detected
|
||||||
if (mon->getEvent(ev, 2)) {
|
if (mon->getEvent(ev, 2)) {
|
||||||
if (ev.m_etyp == RclMonEvent::RCLEVT_DIRCREATE) {
|
if (ev.m_etyp == RclMonEvent::RCLEVT_DIRCREATE) {
|
||||||
mon->addWatch(ev.m_path, true);
|
// Add watch after checking that this doesn't match
|
||||||
|
// ignored files or paths
|
||||||
|
string name = path_getsimple(ev.m_path);
|
||||||
|
if (!walker.inSkippedNames(name) &&
|
||||||
|
!walker.inSkippedPaths(ev.m_path))
|
||||||
|
mon->addWatch(ev.m_path, true);
|
||||||
}
|
}
|
||||||
if (ev.m_etyp != RclMonEvent::RCLEVT_NONE)
|
if (ev.m_etyp != RclMonEvent::RCLEVT_NONE)
|
||||||
queue->pushEvent(ev);
|
queue->pushEvent(ev);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.11 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.12 2007-07-12 10:53:07 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -89,6 +89,17 @@ bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
|
|||||||
data->skippedNames.unique();
|
data->skippedNames.unique();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool FsTreeWalker::inSkippedNames(const string& name)
|
||||||
|
{
|
||||||
|
list<string>::const_iterator it;
|
||||||
|
for (it = data->skippedNames.begin();
|
||||||
|
it != data->skippedNames.end(); it++) {
|
||||||
|
if (fnmatch(it->c_str(), name.c_str(), 0) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool FsTreeWalker::addSkippedPath(const string& ipath)
|
bool FsTreeWalker::addSkippedPath(const string& ipath)
|
||||||
{
|
{
|
||||||
@ -108,6 +119,16 @@ bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
|
|||||||
data->skippedPaths.unique();
|
data->skippedPaths.unique();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
FsTreeWalker::Status FsTreeWalker::walk(const string &top,
|
FsTreeWalker::Status FsTreeWalker::walk(const string &top,
|
||||||
FsTreeWalkerCB& cb)
|
FsTreeWalkerCB& cb)
|
||||||
@ -156,20 +177,14 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
|||||||
|
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
while ((ent = readdir(d)) != 0) {
|
while ((ent = readdir(d)) != 0) {
|
||||||
// We do process hidden files for now, only skip . and ..
|
// Skip . and ..
|
||||||
if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
|
if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Skipped file names match ?
|
||||||
if (!data->skippedNames.empty()) {
|
if (!data->skippedNames.empty()) {
|
||||||
list<string>::const_iterator it;
|
if (inSkippedNames(ent->d_name))
|
||||||
for (it = data->skippedNames.begin();
|
goto skip;
|
||||||
it != data->skippedNames.end(); it++) {
|
|
||||||
if (fnmatch(it->c_str(), ent->d_name, 0) == 0) {
|
|
||||||
//fprintf(stderr,
|
|
||||||
//"Skipping [%s] because of pattern match\n", ent->d_name);
|
|
||||||
goto skip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -183,12 +198,8 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!data->skippedPaths.empty()) {
|
if (!data->skippedPaths.empty()) {
|
||||||
list<string>::const_iterator it;
|
if (inSkippedPaths(fn))
|
||||||
for (it = data->skippedPaths.begin();
|
goto skip;
|
||||||
it != data->skippedPaths.end(); it++) {
|
|
||||||
if (fnmatch(it->c_str(), fn.c_str(), FNM_PATHNAME) == 0)
|
|
||||||
goto skip;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _FSTREEWALK_H_INCLUDED_
|
#ifndef _FSTREEWALK_H_INCLUDED_
|
||||||
#define _FSTREEWALK_H_INCLUDED_
|
#define _FSTREEWALK_H_INCLUDED_
|
||||||
/* @(#$Id: fstreewalk.h,v 1.6 2006-12-21 08:22:35 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: fstreewalk.h,v 1.7 2007-07-12 10:53:07 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -71,6 +71,8 @@ class FsTreeWalker {
|
|||||||
/** Set the ignored paths list */
|
/** Set the ignored paths list */
|
||||||
bool setSkippedPaths(const list<string> &pathlist);
|
bool setSkippedPaths(const list<string> &pathlist);
|
||||||
|
|
||||||
|
bool inSkippedPaths(const string& path);
|
||||||
|
bool inSkippedNames(const string& name);
|
||||||
private:
|
private:
|
||||||
Status iwalk(const string &dir, FsTreeWalkerCB& cb);
|
Status iwalk(const string &dir, FsTreeWalkerCB& cb);
|
||||||
class Internal;
|
class Internal;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user