ofxIO
ofxIO copied to clipboard
Directory watcher trigger events no matter the file filter given
Hi,
It seems that the directory watcher doesn't take care of the path filter we give him when adding a path.
If I make a custom path filter where I only want to see "wav" files for example:
class WavPathFilter : public ofxIO::AbstractPathFilter
{
public:
WavPathFilter() {}
virtual ~WavPathFilter() {}
bool accept(const Poco::Path& path) const
{
// Return only .wav file
return path.getExtension() == "wav";
}
};
And use this filter to add a path to my directory watcher
ofxIO::DirectoryWatcherManager watcher;
WavPathFilter wavFilter;
watcher.addPath(folder_to_watch, false, false, &wavFilter);
Then no matter which type file is modified inside the folder to watch, the directory watcher will trigger events. I noticed the same behavior in the example project as well (with hidden files).
Though if I use the same filter to list the folder directory, then it works: I only get "wav" files listed in my vector.
vector<string> myFiles;
ofxIO::DirectoryUtils::list(folder_to_watch, myFiles, true, &wavFilter);
How can I have the directory watcher filter out the files I am not interested in directly?
I am on stable branch.
Thanks
Hi, do you get the same issue on the master branch? The stable branch is several years old and not actively supported.
I get this issue on macOS 10.14.6 with OF 0.11 using the current master branch.
class CustomPathFilter: public ofxIO::AbstractPathFilter
{
public:
CustomPathFilter()
{
}
virtual ~CustomPathFilter()
{
}
bool accept(const Poco::Path& path) const
{
return !Poco::File(path).isHidden() &&
!ofIsStringInString(path.toString(), "temp_output");
}
};
watcher.addPath(svg_folderToWatch, listExistingItemsOnStart, &pathFilter);