00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __EDELIB_DIRWATCH_H__
00022 #define __EDELIB_DIRWATCH_H__
00023
00024 #include "edelib-global.h"
00025
00026 EDELIB_NS_BEGIN
00027
00032 enum DirWatchFlags {
00033 DW_CREATE = (1 << 1),
00034 DW_MODIFY = (1 << 2),
00035 DW_ACCESS = (1 << 3),
00036 DW_RENAME = (1 << 4),
00037 DW_ATTRIB = (1 << 5),
00038 DW_DELETE = (1 << 6)
00039 };
00040
00045 enum DirWatchNotifier {
00046 DW_NONE = 0,
00047 DW_INOTIFY,
00048 DW_FAM
00049 };
00050
00055 enum DirWatchReportFlags {
00056 DW_REPORT_NONE = -1,
00057 DW_REPORT_CREATE = 0,
00058 DW_REPORT_MODIFY,
00059 DW_REPORT_RENAME,
00060 DW_REPORT_DELETE
00061 };
00062
00063 struct DirWatchEntry;
00064 struct DirWatchImpl;
00065
00066 #ifndef SKIP_DOCS
00067 typedef void (DirWatchCallback)(const char* dir, const char* w, int flags, void* data);
00068 #endif
00069
00180 class EDELIB_API DirWatch {
00181 private:
00182 static DirWatch* pinstance;
00183
00184 DirWatchImpl* impl;
00185 DirWatchNotifier backend_notifier;
00186
00187 bool init_backend(void);
00188
00189 E_DISABLE_CLASS_COPY(DirWatch)
00190 public:
00194 DirWatch();
00195
00199 ~DirWatch();
00200
00201 #ifndef SKIP_DOCS
00202 static DirWatch* instance(void);
00203
00204 bool add_entry(const char* dir, int flags);
00205 bool remove_entry(const char* dir);
00206 bool have_entry(const char* dir);
00207 void add_callback(DirWatchCallback* cb, void* data);
00208 void run_callback(int fd);
00209 DirWatchNotifier get_notifier(void) { return backend_notifier; }
00210 #endif
00211
00215 static bool init(void);
00216
00221 static void shutdown(void);
00222
00228 static bool add(const char* dir, int flags);
00229
00233 static bool remove(const char* dir);
00234
00239 static void callback(DirWatchCallback& cb, void* data = 0);
00240
00244 static DirWatchNotifier notifier(void);
00245 };
00246
00247 EDELIB_NS_END
00248 #endif