blob: 861248e0055b2ca626fedd404ef66eb11bcaf23a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|