diff options
Diffstat (limited to 'server/src/inotify.h')
-rw-r--r-- | server/src/inotify.h | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/server/src/inotify.h b/server/src/inotify.h index a2503b3..5199055 100644 --- a/server/src/inotify.h +++ b/server/src/inotify.h @@ -35,42 +35,70 @@ #include <map> #include <list> +typedef enum { + WATCH_SINGLE, // Watch only the specified directory. + WATCH_DEEP, // Watch all current subdirs as well + WATCH_DEEP_FOLLOW // Watch all current subdir as well as subdirs + // being created after the watch is initiated +} depth_t; + + class INotify { public: class Event { public: - Event(std::string name, uint32_t mask); + Event(struct inotify_event *event, std::string name); bool isAttributeChangeEvent(); + bool isCreateEvent(); bool isOpenEvent(); bool isCloseEvent(); + bool isCloseWriteEvent(); + bool isCloseNoWriteEvent(); bool isModifyEvent(); + bool isAccessEvent(); bool isDeleteEvent(); + bool isDeleteSelfEvent(); + bool isIgnoredEvent(); + bool isMoveSelfEvent(); + bool isMovedFromEvent(); + bool isMovedToEvent(); std::string name(); + std::string file(); uint32_t mask(); private: std::string _name; + std::string _file; uint32_t _mask; }; INotify(); ~INotify(); - void add(std::string name, uint32_t mask = IN_ALL_EVENTS); + void addFile(std::string name, uint32_t mask = IN_ALL_EVENTS); + void addDirectory(std::string name, + depth_t depth = WATCH_SINGLE, + uint32_t mask = IN_ALL_EVENTS); void remove(std::string name); void remove(int fd); - void addRecursive(std::string name, uint32_t mask = IN_ALL_EVENTS); - bool hasEvents(); Event getNextEvent(); private: + class Watch { + public: + std::string name; + uint32_t mask; + depth_t depth; + }; + void readEvents(); - int fd; - std::map<int, std::string> dirmap; + + int ifd; + std::map<int, Watch> dirmap; std::list<Event> eventlist; }; |