#ifndef CHANGEWATCHER_H #define CHANGEWATCHER_H #include #include #include #include class ChangeWatcher { int m_fdnotify; int m_fdevent; bool m_enabled {false}; std::thread m_thread; std::vector m_watches; std::map m_wd; std::function m_filewrited {}; std::function m_fileadded; std::function m_fileremoved; public: explicit ChangeWatcher(); virtual ~ChangeWatcher(); void watch(const std::string &newPath); void setEnable(bool newVal); bool enabled() const; void setFileWrited(const std::function &callback); void setFileAdded(const std::function &callback); void setFileRemoved(const std::function &callback); private: static void _runningLoop(ChangeWatcher *m); void _addWatch(const std::string& newPath); }; #endif // CHANGEWATCHER_H