fawkes::FileAlterationMonitor Class Reference
Monitors files for changes. More...
#include <utils/system/fam.h>
Public Member Functions | |
| FileAlterationMonitor () | |
| Constructor. | |
| ~FileAlterationMonitor () | |
| Destructor. | |
| void | watch_dir (const char *dirpath) |
| Watch a directory. | |
| void | add_filter (const char *regex) |
| Add a filter. | |
| void | process_events (int timeout=0) |
| Process events. | |
| void | add_listener (FamListener *listener) |
| Add a listener. | |
| void | remove_listener (FamListener *listener) |
| Remove a listener. | |
Detailed Description
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.
Definition at line 71 of file fam.h.
Constructor & Destructor Documentation
| fawkes::FileAlterationMonitor::FileAlterationMonitor | ( | ) |
| fawkes::FileAlterationMonitor::~FileAlterationMonitor | ( | ) |
Member Function Documentation
| 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
^[^.].*\\.lua$
- Parameters:
-
regex regular expression to add
Definition at line 209 of file fam.cpp.
References fawkes::LockList< Type >::push_back_locked().
Referenced by fawkes::LuaContext::LuaContext().
| void fawkes::FileAlterationMonitor::add_listener | ( | FamListener * | listener | ) |
Add a listener.
- Parameters:
-
listener listener to add
Definition at line 227 of file fam.cpp.
References fawkes::LockList< Type >::push_back_locked().
Referenced by fawkes::LuaContext::LuaContext().
| void fawkes::FileAlterationMonitor::process_events | ( | int | timeout = 0 |
) |
Process events.
Call this when you want file events to be processed.
- Parameters:
-
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 249 of file fam.cpp.
References fawkes::LibLogger::log_error(), fawkes::LibLogger::log_warn(), and watch_dir().
Referenced by fawkes::LuaContext::process_fam_events().
| void fawkes::FileAlterationMonitor::remove_listener | ( | FamListener * | listener | ) |
Remove a listener.
- Parameters:
-
listener listener to remove
Definition at line 237 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.
- Parameters:
-
dirpath path to directory to add
Definition at line 150 of file fam.cpp.
References fawkes::LibLogger::log_debug().
Referenced by fawkes::LuaContext::add_cpackage_dir(), fawkes::LuaContext::add_package_dir(), and process_events().
The documentation for this class was generated from the following files:

