From c3a1946675855b299a2b36550cdf2c2f69d153aa Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 17 Sep 2012 23:03:03 +0200 Subject: initial import --- distfoldd/watcher.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 distfoldd/watcher.h (limited to 'distfoldd/watcher.h') diff --git a/distfoldd/watcher.h b/distfoldd/watcher.h new file mode 100644 index 0000000..861248e --- /dev/null +++ b/distfoldd/watcher.h @@ -0,0 +1,38 @@ +#ifndef WATCHER_H +#define WATCHER_H + +#include +#include +#include +#include + +class Watcher : public QObject +{ + Q_OBJECT +public: + explicit Watcher(const QString& path, QObject *parent = 0); + +signals: + void pathAdded(const QString& path); + void pathRemoved(const QString& path); + void pathChanged(const QString& path); + +private slots: + void readInotify(); + +private: + QStringList scanDirs(const QDir& dir); + void addWatch(const QString& path); + void removeWatch(const QString& path); + void removeWatch(int wd); + +private: + int _fd; + QSocketNotifier *_notifier; + quint32 _mask; + QByteArray _buffer; + QMap _watches; + QHash _dirs; +}; + +#endif // WATCHER_H -- cgit v1.2.3