Fawkes API  Fawkes Development Version
fawkes::FileAlterationMonitor Class Reference

#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...
 

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.

Author
Tim Niemueller

Definition at line 74 of file fam.h.

Constructor & Destructor Documentation

◆ FileAlterationMonitor()

fawkes::FileAlterationMonitor::FileAlterationMonitor ( )

Constructor.

Opens the inotify context.

Definition at line 112 of file fam.cpp.

◆ ~FileAlterationMonitor()

fawkes::FileAlterationMonitor::~FileAlterationMonitor ( )

Destructor.

Definition at line 135 of file fam.cpp.

Member Function Documentation

◆ add_filter()

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$

This regular expression matches to all files that does not start with a dot and have an .lua ending.

Parameters
regexregular expression to add

Definition at line 250 of file fam.cpp.

◆ add_listener()

void fawkes::FileAlterationMonitor::add_listener ( FamListener listener)

Add a listener.

Parameters
listenerlistener to add

Definition at line 267 of file fam.cpp.

Referenced by NavGraphThread::init().

◆ interrupt()

void fawkes::FileAlterationMonitor::interrupt ( )

Interrupt a running process_events().

This method will interrupt e.g. a running inifinetly blocking call of process_events().

Definition at line 417 of file fam.cpp.

◆ process_events()

void fawkes::FileAlterationMonitor::process_events ( int  timeout = 0)

Process events.

Call this when you want file events to be processed.

Parameters
timeouttimeout 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 287 of file fam.cpp.

Referenced by NavGraphThread::loop().

◆ remove_listener()

void fawkes::FileAlterationMonitor::remove_listener ( FamListener listener)

Remove a listener.

Parameters
listenerlistener to remove

Definition at line 276 of file fam.cpp.

◆ reset()

void fawkes::FileAlterationMonitor::reset ( void  )

Remove all currently active watches.

Definition at line 226 of file fam.cpp.

◆ watch_dir()

void fawkes::FileAlterationMonitor::watch_dir ( const char *  dirpath)

Watch a directory.

This adds the given directory recursively to this FAM.

Parameters
dirpathpath to directory to add

Definition at line 160 of file fam.cpp.

◆ watch_file()

void fawkes::FileAlterationMonitor::watch_file ( const char *  filepath)

Watch a file.

This adds the given fileto this FAM.

Parameters
filepathpath to file to add

Definition at line 209 of file fam.cpp.

Referenced by NavGraphThread::fam_event(), and NavGraphThread::init().


The documentation for this class was generated from the following files: