Root/src/monitor.h

1#ifndef __MONITOR_H__
2#define __MONITOR_H__
3#ifdef ENABLE_INOTIFY
4
5#include <pthread.h>
6#include <string>
7#include <sys/inotify.h>
8
9class Monitor {
10public:
11    Monitor(std::string path, unsigned int flags = IN_MOVE |
12                IN_CLOSE_WRITE | IN_DELETE | IN_CREATE |
13                IN_DELETE_SELF | IN_MOVE_SELF);
14    virtual ~Monitor();
15
16    int run(void);
17    const std::string getPath(void) { return path; }
18
19private:
20    std::string path;
21    pthread_t thd;
22
23protected:
24    unsigned int mask;
25    virtual bool event_accepted(struct inotify_event &event);
26    virtual void inject_event(bool is_add, const char *path);
27};
28
29#endif
30#endif /* __MONITOR_H__ */
31

Archive Download this file



interactive