2013-07-16 20:36:18 +03:00
|
|
|
#ifndef __MONITOR_H__
|
|
|
|
#define __MONITOR_H__
|
2013-07-19 04:32:23 +03:00
|
|
|
#ifdef ENABLE_INOTIFY
|
2013-07-16 20:36:18 +03:00
|
|
|
|
|
|
|
#include <pthread.h>
|
2013-07-19 04:32:23 +03:00
|
|
|
#include <string>
|
|
|
|
#include <sys/inotify.h>
|
2013-07-16 20:36:18 +03:00
|
|
|
|
|
|
|
class Monitor {
|
|
|
|
public:
|
2013-07-19 04:32:23 +03:00
|
|
|
Monitor(std::string path, unsigned int flags = IN_MOVE |
|
2013-07-19 18:47:27 +03:00
|
|
|
IN_CLOSE_WRITE | IN_DELETE | IN_CREATE |
|
|
|
|
IN_DELETE_SELF | IN_MOVE_SELF);
|
2013-07-19 04:32:23 +03:00
|
|
|
virtual ~Monitor();
|
|
|
|
|
2014-08-15 15:01:11 +03:00
|
|
|
int run();
|
|
|
|
const std::string getPath() { return path; }
|
2013-07-16 20:36:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string path;
|
|
|
|
pthread_t thd;
|
2013-07-19 04:32:23 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int mask;
|
|
|
|
virtual bool event_accepted(struct inotify_event &event);
|
|
|
|
virtual void inject_event(bool is_add, const char *path);
|
2013-07-16 20:36:18 +03:00
|
|
|
};
|
|
|
|
|
2013-07-19 04:32:23 +03:00
|
|
|
#endif
|
2013-07-16 20:36:18 +03:00
|
|
|
#endif /* __MONITOR_H__ */
|