DirWatch.h
/*
* $Id: DirWatch.h 2839 2009-09-28 11:36:20Z karijes $
*
* Directory changes notifier
* Copyright (c) 2005-2007 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_DIRWATCH_H__
#define __EDELIB_DIRWATCH_H__
#include "edelib-global.h"
EDELIB_NS_BEGIN
enum DirWatchFlags {
DW_CREATE = (1 << 1),
DW_MODIFY = (1 << 2),
DW_ACCESS = (1 << 3),
DW_RENAME = (1 << 4),
DW_ATTRIB = (1 << 5),
DW_DELETE = (1 << 6)
};
enum DirWatchNotifier {
DW_NONE = 0,
DW_INOTIFY,
DW_FAM
};
enum DirWatchReportFlags {
DW_REPORT_NONE = -1,
DW_REPORT_CREATE = 0,
DW_REPORT_MODIFY,
DW_REPORT_RENAME,
DW_REPORT_DELETE
};
struct DirWatchEntry;
struct DirWatchImpl;
#ifndef SKIP_DOCS
typedef void (DirWatchCallback)(const char* dir, const char* w, int flags, void* data);
#endif
class EDELIB_API DirWatch {
private:
static DirWatch* pinstance;
DirWatchImpl* impl;
DirWatchNotifier backend_notifier;
bool init_backend(void);
E_DISABLE_CLASS_COPY(DirWatch)
public:
DirWatch();
~DirWatch();
#ifndef SKIP_DOCS
static DirWatch* instance(void);
bool add_entry(const char* dir, int flags);
bool remove_entry(const char* dir);
bool have_entry(const char* dir);
void add_callback(DirWatchCallback* cb, void* data);
void run_callback(int fd);
DirWatchNotifier get_notifier(void) { return backend_notifier; }
#endif
static bool init(void);
static void shutdown(void);
static bool add(const char* dir, int flags);
static bool remove(const char* dir);
static void callback(DirWatchCallback& cb, void* data = 0);
static DirWatchNotifier notifier(void);
};
EDELIB_NS_END
#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