edelib 2.1.0
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
26EDELIB_NS_BEGIN
27
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
46 DW_NONE = 0,
48 DW_FAM
49};
50
61};
62
63struct DirWatchEntry;
64struct DirWatchImpl;
65
66#ifndef SKIP_DOCS
67typedef void (DirWatchCallback)(const char* dir, const char* w, int flags, void* data);
68#endif
69
180class EDELIB_API DirWatch {
181private:
182 static DirWatch* pinstance;
183
184 DirWatchImpl* impl;
185 DirWatchNotifier backend_notifier;
186
187 bool init_backend(void);
188
190public:
195
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
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
245};
246
247EDELIB_NS_END
248#endif
Directory changes notifier.
Definition: DirWatch.h:180
static DirWatchNotifier notifier(void)
static bool remove(const char *dir)
static bool add(const char *dir, int flags)
static void callback(DirWatchCallback &cb, void *data=0)
static bool init(void)
static void shutdown(void)
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
DirWatchNotifier
Notifier type used by DirWatch.
Definition: DirWatch.h:45
@ DW_NONE
None notifier; watching disabled.
Definition: DirWatch.h:46
@ DW_INOTIFY
inotify (linux kernel >= 2.6.13)
Definition: DirWatch.h:47
@ DW_FAM
FAM/gamin.
Definition: DirWatch.h:48
DirWatchReportFlags
Returned codes for received event.
Definition: DirWatch.h:55
@ DW_REPORT_DELETE
Existing item was deleted.
Definition: DirWatch.h:60
@ DW_REPORT_NONE
Not figured out what happened.
Definition: DirWatch.h:56
@ DW_REPORT_CREATE
A new item was created.
Definition: DirWatch.h:57
@ DW_REPORT_MODIFY
Existing item was modified.
Definition: DirWatch.h:58
@ DW_REPORT_RENAME
Existing item was renamed.
Definition: DirWatch.h:59
DirWatchFlags
Flags telling to DirWatch what changes to monitor.
Definition: DirWatch.h:32
@ DW_ACCESS
In directory item is accessed (read, ...)
Definition: DirWatch.h:35
@ DW_CREATE
In directory item created.
Definition: DirWatch.h:33
@ DW_ATTRIB
In directory item's attributes changed.
Definition: DirWatch.h:37