ofxIO icon indicating copy to clipboard operation
ofxIO copied to clipboard

Directory watcher trigger events no matter the file filter given

Open Meach opened this issue 7 years ago • 2 comments

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

Meach avatar Feb 07 '18 09:02 Meach

Hi, do you get the same issue on the master branch? The stable branch is several years old and not actively supported.

bakercp avatar Mar 03 '18 14:03 bakercp

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);

stephanschulz avatar Oct 05 '20 20:10 stephanschulz