Root/
| 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 | |
| 9 | class Monitor { |
| 10 | public: |
| 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(); |
| 17 | const std::string getPath() { return path; } |
| 18 | |
| 19 | private: |
| 20 | std::string path; |
| 21 | pthread_t thd; |
| 22 | |
| 23 | protected: |
| 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 |
Branches:
install_locations
master
opkrun
packages
