25 #ifndef COMMON_UTILS_INOTIFY_HPP
26 #define COMMON_UTILS_INOTIFY_HPP
34 #include <sys/inotify.h>
45 typedef std::function<void(const std::string&, const uint32_t)>
Callback;
56 void setHandler(
const std::string& path,
const uint32_t eventMask,
const Callback&& callback);
75 typedef std::lock_guard<std::recursive_mutex>
Lock;
88 #endif // COMMON_UTILS_INOTIFY_HPP
void setHandler(const std::string &path, const uint32_t eventMask, const Callback &&callback)
Add a callback for a specified path.
Definition: inotify.cpp:75
Definition: inotify.hpp:69
void handleInternal()
Definition: inotify.cpp:122
std::string path
Definition: inotify.hpp:70
std::lock_guard< std::recursive_mutex > Lock
Definition: inotify.hpp:75
void removeHandlerInternal(const std::string &path)
Definition: inotify.cpp:94
Callback call
Definition: inotify.hpp:72
Inotify & operator=(const Inotify &)=delete
void removeHandler(const std::string &path)
Stop watching the path.
Definition: inotify.cpp:115
std::recursive_mutex mMutex
Definition: inotify.hpp:76
std::function< void(const std::string &, const uint32_t)> Callback
Definition: inotify.hpp:45
Inotify monitors a directory and when a specified file or folder is created or deleted it calls a cor...
Definition: inotify.hpp:43
std::vector< Handler > mHandlers
Definition: inotify.hpp:80
virtual ~Inotify()
Definition: inotify.cpp:54
cargo::ipc::epoll::EventPoll & mEventPoll
Definition: inotify.hpp:79
int mFD
Definition: inotify.hpp:78
Inotify(cargo::ipc::epoll::EventPoll &eventPoll)
Definition: inotify.cpp:41
This class waits on registered file descriptor for events.
Definition: event-poll.hpp:47
int watchID
Definition: inotify.hpp:71
int getFD() const
Definition: inotify.cpp:70