Skip to content

Instantly share code, notes, and snippets.

@trentbrooks
Created November 13, 2015 03:30
Show Gist options
  • Save trentbrooks/d6c63496b28b2ce1b11b to your computer and use it in GitHub Desktop.
Save trentbrooks/d6c63496b28b2ce1b11b to your computer and use it in GitHub Desktop.
OF/Poco directory watcher minimal example
// ofApp.h
#include "Poco/DirectoryWatcher.h"
#include "Poco/Delegate.h"
Poco::DirectoryWatcher* watcher;
void onFileAdded(const Poco::DirectoryWatcher::DirectoryEvent& addEvent);
void onFileChanged(const Poco::DirectoryWatcher::DirectoryEvent& changeEvent);
// ofApp.cpp
watcher = new Poco::DirectoryWatcher(ofToDataPath("img"));
watcher->itemAdded += Poco::delegate(this, &ofApp::onFileAdded);
watcher->itemModified += Poco::delegate(this, &ofApp::onFileChanged);
void ofApp::onFileAdded(const Poco::DirectoryWatcher::DirectoryEvent& addEvent) {
ofLog() << "Added: " << addEvent.item.path();
}
void ofApp::onFileChanged(const Poco::DirectoryWatcher::DirectoryEvent& changeEvent) {
ofLog() << "Changed: " << addEvent.item.path();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment