Fawkes API
Fawkes Development Version
|
Monitors files for changes. More...
#include <>>
Public Member Functions | |
FileAlterationMonitor () | |
Constructor. More... | |
~FileAlterationMonitor () | |
Destructor. More... | |
void | watch_dir (const char *dirpath) |
Watch a directory. More... | |
void | watch_file (const char *filepath) |
Watch a file. More... | |
void | add_filter (const char *regex) |
Add a filter. More... | |
void | reset () |
Remove all currently active watches. More... | |
void | process_events (int timeout=0) |
Process events. More... | |
void | interrupt () |
Interrupt a running process_events(). More... | |
void | add_listener (FamListener *listener) |
Add a listener. More... | |
void | remove_listener (FamListener *listener) |
Remove a listener. More... | |
Monitors files for changes.
This is a wrapper around inotify. It will watch directories and files for modifications. If a modifiacation, removal or addition of a file is detected one or more listeners are called. The files which trigger the event can be constrained with regular expressions.
fawkes::FileAlterationMonitor::FileAlterationMonitor | ( | ) |
fawkes::FileAlterationMonitor::~FileAlterationMonitor | ( | ) |
void fawkes::FileAlterationMonitor::add_filter | ( | const char * | regex | ) |
Add a filter.
Filters are applied to path names that triggered an event. All pathnames are checked against this regex and if any does not match the event is not posted to listeners. An example regular expression is
This regular expression matches to all files that does not start with a dot and have an .lua ending.
regex | regular expression to add |
Definition at line 249 of file fam.cpp.
References fawkes::LockList< Type >::push_back_locked().
void fawkes::FileAlterationMonitor::add_listener | ( | FamListener * | listener | ) |
Add a listener.
listener | listener to add |
Definition at line 267 of file fam.cpp.
Referenced by NavGraphThread::init().
void fawkes::FileAlterationMonitor::interrupt | ( | ) |
Interrupt a running process_events().
This method will interrupt e.g. a running inifinetly blocking call of process_events().
void fawkes::FileAlterationMonitor::process_events | ( | int | timeout = 0 | ) |
Process events.
Call this when you want file events to be processed.
timeout | timeout in milliseconds to wait for an event, 0 to just check and no wait, -1 to wait forever until an event is received |
Definition at line 289 of file fam.cpp.
References watch_dir().
Referenced by NavGraphThread::loop().
void fawkes::FileAlterationMonitor::remove_listener | ( | FamListener * | listener | ) |
void fawkes::FileAlterationMonitor::reset | ( | void | ) |
void fawkes::FileAlterationMonitor::watch_dir | ( | const char * | dirpath | ) |
Watch a directory.
This adds the given directory recursively to this FAM.
dirpath | path to directory to add |
Definition at line 158 of file fam.cpp.
Referenced by process_events().
void fawkes::FileAlterationMonitor::watch_file | ( | const char * | filepath | ) |
Watch a file.
This adds the given fileto this FAM.
filepath | path to file to add |
Definition at line 207 of file fam.cpp.
Referenced by NavGraphThread::fam_event(), and NavGraphThread::init().