| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QFILESYSTEMWATCHER_INOTIFY_P_H |
| 5 | #define QFILESYSTEMWATCHER_INOTIFY_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qfilesystemwatcher_p.h" |
| 19 | |
| 20 | QT_REQUIRE_CONFIG(filesystemwatcher); |
| 21 | |
| 22 | #include <QtCore/qhash.h> |
| 23 | #include <QtCore/qmutex.h> |
| 24 | #include <QtCore/qsocketnotifier.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QInotifyFileSystemWatcherEngine : public QFileSystemWatcherEngine |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | public: |
| 33 | ~QInotifyFileSystemWatcherEngine(); |
| 34 | |
| 35 | static QInotifyFileSystemWatcherEngine *create(QObject *parent); |
| 36 | |
| 37 | QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override; |
| 38 | QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override; |
| 39 | |
| 40 | private Q_SLOTS: |
| 41 | void readFromInotify(); |
| 42 | |
| 43 | private: |
| 44 | QString getPathFromID(int id) const; |
| 45 | |
| 46 | private: |
| 47 | QInotifyFileSystemWatcherEngine(int fd, QObject *parent); |
| 48 | int inotifyFd; |
| 49 | QHash<QString, int> pathToID; |
| 50 | QMultiHash<int, QString> idToPath; |
| 51 | QSocketNotifier notifier; |
| 52 | }; |
| 53 | |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | #endif // QFILESYSTEMWATCHER_INOTIFY_P_H |
| 57 | |