SOFA API  1c8b807d
Open source framework for multi-physics simuation
sofa::helper::system::FileMonitor Class Reference

#include <FileMonitor.h>

Static Public Member Functions

static int addFile (const std::string &filename, FileEventListener *listener)
 add a new filepath to monitor and a listener to be triggered in case of change. returns >= 0 if the file was successfully added returns < 0 in case of error. More...
 
static int addFile (const std::string &directoryname, const std::string &filename, FileEventListener *listener)
 add a new path and file to monitor and a listener to be triggered in case of change. returns >= 0 if the file was successfully added returns < 0 in case of error. More...
 
static int updates (int timeout=1)
 check if the file have changed, colalesc the similar events and notify the listener. timeout is the number of seconds to block the calling process. Can be 0 (in this case it return immediately if there is no event. return -1 in case of error return >= 0 otherwise. More...
 
static void removeListener (FileEventListener *listener)
 remove the provided listener. If the listener is not existing, do nothing If the listener is nullptr, do nothing If the listener is associated with one or more file...remove all the associations. Keep in mind that the file are still monitored. More...
 
static void removeFileListener (const std::string &filename, FileEventListener *listener)
 remove the provided listener for a given file If the listener is not existing, do nothing If the listener is nullptr, do nothing If the listener is associated with one or more file...remove all the associations. Keep in mind that the file are still monitored. More...
 

Function details

◆ addFile() [1/2]

int sofa::helper::system::FileMonitor::addFile ( const std::string &  directoryname,
const std::string &  filename,
FileEventListener listener 
)
static

add a new path and file to monitor and a listener to be triggered in case of change. returns >= 0 if the file was successfully added returns < 0 in case of error.

◆ addFile() [2/2]

int sofa::helper::system::FileMonitor::addFile ( const std::string &  filename,
FileEventListener listener 
)
static

add a new filepath to monitor and a listener to be triggered in case of change. returns >= 0 if the file was successfully added returns < 0 in case of error.

◆ removeFileListener()

void sofa::helper::system::FileMonitor::removeFileListener ( const std::string &  filename,
FileEventListener listener 
)
static

remove the provided listener for a given file If the listener is not existing, do nothing If the listener is nullptr, do nothing If the listener is associated with one or more file...remove all the associations. Keep in mind that the file are still monitored.

◆ removeListener()

void sofa::helper::system::FileMonitor::removeListener ( FileEventListener listener)
static

remove the provided listener. If the listener is not existing, do nothing If the listener is nullptr, do nothing If the listener is associated with one or more file...remove all the associations. Keep in mind that the file are still monitored.

◆ updates()

int sofa::helper::system::FileMonitor::updates ( int  timeout = 1)
static

check if the file have changed, colalesc the similar events and notify the listener. timeout is the number of seconds to block the calling process. Can be 0 (in this case it return immediately if there is no event. return -1 in case of error return >= 0 otherwise.