Fawkes API
Fawkes Development Version
|
Monitors files for changes. More...
#include <>>
Public Member Functions | |
FileAlterationMonitor () | |
Constructor. | |
~FileAlterationMonitor () | |
Destructor. | |
void | watch_dir (const char *dirpath) |
Watch a directory. | |
void | watch_file (const char *filepath) |
Watch a file. | |
void | add_filter (const char *regex) |
Add a filter. | |
void | process_events (int timeout=0) |
Process events. | |
void | interrupt () |
Interrupt a running process_events(). | |
void | add_listener (FamListener *listener) |
Add a listener. | |
void | remove_listener (FamListener *listener) |
Remove a listener. |
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 231 of file fam.cpp.
References fawkes::LockList< Type >::push_back_locked().
Referenced by fawkes::PluginManager::PluginManager().
void fawkes::FileAlterationMonitor::add_listener | ( | FamListener * | listener | ) |
Add a listener.
listener | listener to add |
Definition at line 249 of file fam.cpp.
References fawkes::LockList< Type >::push_back_locked().
Referenced by LuaAgentContinuousExecutionThread::init(), and fawkes::PluginManager::PluginManager().
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 271 of file fam.cpp.
References watch_dir().
Referenced by fawkes::FamThread::loop().
void fawkes::FileAlterationMonitor::remove_listener | ( | FamListener * | listener | ) |
Remove a listener.
listener | listener to remove |
Definition at line 259 of file fam.cpp.
References fawkes::LockList< Type >::remove_locked().
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 153 of file fam.cpp.
Referenced by fawkes::PluginManager::PluginManager(), and process_events().
void fawkes::FileAlterationMonitor::watch_file | ( | const char * | filepath | ) |