AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
AsyncFw::FileSystemWatcher Class Reference

The FileSystemWatcher class. More...

#include <AsyncFw/FileSystemWatcher>

Collaboration diagram for AsyncFw::FileSystemWatcher:
[legend]

Public Member Functions

 FileSystemWatcher (const std::vector< std::string > &={})
 
bool addPath (const std::string &path)
 
bool addPaths (const std::vector< std::string > &paths)
 
bool removePath (const std::string &path)
 
bool removePaths (const std::vector< std::string > &paths)
 
std::vector< std::string > paths () const
 

Static Public Member Functions

static FileSystemWatcherinstance ()
 

Public Attributes

FunctionConnectorProtected< FileSystemWatcher >::Connector< const std::string &, int > notify
 The FunctionConnector for notification of file-related events.
 

Friends

LogStreamoperator<< (LogStream &log, const FileSystemWatcher &w)
 

Detailed Description

The FileSystemWatcher class.

Warning
Unix-like systems only

Example:

#include <AsyncFw/FileSystemWatcher>
#include <AsyncFw/File>
#include <AsyncFw/MainThread>
#include <AsyncFw/LogStream>
using namespace AsyncFw;
int main(int argc, char *argv[]) {
FileSystemWatcher watcher {{"/tmp/FileSystemWatcher.example"}};
watcher.notify([](const std::string &name, int event) {
lsInfoMagenta() << "file:" << name << event; // event: -1 removed / 0 changed / 1 created
MainThread::exit();
});
File _f {"/tmp/FileSystemWatcher.example"};
if (_f.exists()) _f.remove();
else { _f.open(std::ios::binary | std::ios::out); };
lsInfoGreen() << watcher;
lsNotice() << "Start Applicaiton";
int ret = MainThread::exec();
lsNotice() << "End Applicaiton" << ret;
return ret;
}

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