4#include <qplatformdefs.h>
8#include "private/qcore_unix_p.h"
28# define DEBUG if(false)qDebug
39QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(
int kqfd,
QObject *
parent)
46 fcntl(kqfd, F_SETFD, FD_CLOEXEC);
54 for (
int id : std::as_const(pathToID))
55 ::close(
id < 0 ? -
id :
id);
72 perror(
"QKqueueFileSystemWatcherEngine::addPaths: open");
75 if (
fd >= (
int)FD_SETSIZE / 2 &&
fd < (
int)FD_SETSIZE) {
84 if (QT_FSTAT(
fd, &st) == -1) {
85 perror(
"QKqueueFileSystemWatcherEngine::addPaths: fstat");
89 int id = (S_ISDIR(st.st_mode)) ? -
fd :
fd;
91 if (directories->contains(
path)) {
106 EV_ADD | EV_ENABLE | EV_CLEAR,
107 NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
110 if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) {
111 perror(
"QKqueueFileSystemWatcherEngine::addPaths: kevent");
119 DEBUG() <<
"QKqueueFileSystemWatcherEngine: added directory path" <<
path;
120 directories->append(
path);
122 DEBUG() <<
"QKqueueFileSystemWatcherEngine: added file path" <<
path;
145 if (
x.isEmpty() ||
x !=
path)
148 ::close(
id < 0 ? -
id :
id);
153 directories->removeAll(
path);
161void QKqueueFileSystemWatcherEngine::readFromKqueue()
164 DEBUG() <<
"QKqueueFileSystemWatcherEngine: polling for changes";
167 struct timespec ts = { 0, 0 };
170 perror(
"QKqueueFileSystemWatcherEngine: error during kevent wait");
178 DEBUG() <<
"QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
182 if (
path.isEmpty()) {
186 if (
path.isEmpty()) {
187 DEBUG() <<
"QKqueueFileSystemWatcherEngine: received a kevent for a file we're not watching";
191 if (kev.filter != EVFILT_VNODE) {
192 DEBUG() <<
"QKqueueFileSystemWatcherEngine: received a kevent with the wrong filter";
196 if ((kev.fflags & (NOTE_DELETE | NOTE_REVOKE | NOTE_RENAME)) != 0) {
197 DEBUG() <<
path <<
"removed, removing watch also";
222#include "moc_qfilesystemwatcher_kqueue_p.cpp"
DarwinBluetooth::LECBManagerNotifier * notifier
void directoryChanged(const QString &path, bool removed)
void fileChanged(const QString &path, bool removed)
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
bool remove(const Key &key)
Removes the item that has the key from the hash.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
T value(const Key &key) const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
~QKqueueFileSystemWatcherEngine()
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories) override
static QKqueueFileSystemWatcherEngine * create(QObject *parent)
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories) override
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
static int qt_safe_dup(int oldfd, int atleast=0, int flags=FD_CLOEXEC)
#define EINTR_LOOP(var, cmd)
GLint GLint GLint GLint GLint x
[0]
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent