edelib: edelib/DirWatch.h Source File

edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

DirWatch.h
1 /*
2 * $Id: DirWatch.h 2839 2009-09-28 11:36:20Z karijes $
3 *
4 * Directory changes notifier
5 * Copyright (c) 2005-2007 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_DIRWATCH_H__
22 #define __EDELIB_DIRWATCH_H__
23
24 #include "edelib-global.h"
25
26 EDELIB_NS_BEGIN
27
32 enum DirWatchFlags {
33 DW_CREATE = (1 << 1),
34 DW_MODIFY = (1 << 2),
35 DW_ACCESS = (1 << 3),
36 DW_RENAME = (1 << 4),
37 DW_ATTRIB = (1 << 5),
38 DW_DELETE = (1 << 6)
39 };
40
45 enum DirWatchNotifier {
46 DW_NONE = 0,
47 DW_INOTIFY,
48 DW_FAM
49 };
50
55 enum DirWatchReportFlags {
56 DW_REPORT_NONE = -1,
57 DW_REPORT_CREATE = 0,
58 DW_REPORT_MODIFY,
59 DW_REPORT_RENAME,
60 DW_REPORT_DELETE
61 };
62
63 struct DirWatchEntry;
64 struct DirWatchImpl;
65
66 #ifndef SKIP_DOCS
67 typedef void (DirWatchCallback)(const char* dir, const char* w, int flags, void* data);
68 #endif
69
180 class EDELIB_API DirWatch {
181 private:
182 static DirWatch* pinstance;
183
184 DirWatchImpl* impl;
185 DirWatchNotifier backend_notifier;
186
187 bool init_backend(void);
188
189 E_DISABLE_CLASS_COPY(DirWatch)
190 public:
194 DirWatch();
195
199 ~DirWatch();
200
201 #ifndef SKIP_DOCS
202 static DirWatch* instance(void);
203
204 bool add_entry(const char* dir, int flags);
205 bool remove_entry(const char* dir);
206 bool have_entry(const char* dir);
207 void add_callback(DirWatchCallback* cb, void* data);
208 void run_callback(int fd);
209 DirWatchNotifier get_notifier(void) { return backend_notifier; }
210 #endif
211
215 static bool init(void);
216
221 static void shutdown(void);
222
228 static bool add(const char* dir, int flags);
229
233 static bool remove(const char* dir);
234
239 static void callback(DirWatchCallback& cb, void* data = 0);
240
244 static DirWatchNotifier notifier(void);
245 };
246
247 EDELIB_NS_END
248 #endif
edelib::DW_REPORT_RENAME
Existing item was renamed.
Definition: DirWatch.h:59
edelib::DW_FAM
FAM/gamin.
Definition: DirWatch.h:48
edelib::DW_INOTIFY
inotify (linux kernel >= 2.6.13)
Definition: DirWatch.h:47
edelib::DW_CREATE
In directory item created.
Definition: DirWatch.h:33
edelib::DW_REPORT_CREATE
A new item was created.
Definition: DirWatch.h:57
edelib::DW_ACCESS
In directory item is accessed (read, ...)
Definition: DirWatch.h:35
edelib::DW_NONE
None notifier; watching disabled.
Definition: DirWatch.h:46
edelib::DW_REPORT_NONE
Not figured out what happened.
Definition: DirWatch.h:56
edelib::DW_ATTRIB
In directory item&#39;s attributes changed.
Definition: DirWatch.h:37
edelib::DW_REPORT_DELETE
Existing item was deleted.
Definition: DirWatch.h:60
edelib::DirWatchReportFlags
DirWatchReportFlags
Returned codes for received event.
Definition: DirWatch.h:55
edelib::DW_REPORT_MODIFY
Existing item was modified.
Definition: DirWatch.h:58
edelib::DirWatchNotifier
DirWatchNotifier
Notifier type used by DirWatch.
Definition: DirWatch.h:45
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::DirWatch
Directory changes notifier.
Definition: DirWatch.h:180
edelib::DirWatchFlags
DirWatchFlags
Flags telling to DirWatch what changes to monitor.
Definition: DirWatch.h:32