summaryrefslogtreecommitdiff
path: root/distfoldd/watcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'distfoldd/watcher.h')
-rw-r--r--distfoldd/watcher.h38
1 files changed, 38 insertions, 0 deletions
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 <QtCore/QDir>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/QMap>
+#include <QtCore/QHash>
+
+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<int, QString> _watches;
+ QHash<QString, int> _dirs;
+};
+
+#endif // WATCHER_H