14#if (defined(Q_OS_LINUX) || defined(Q_OS_QNX)) && QT_CONFIG(inotify)
21#elif defined(USE_INOTIFY)
23#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
25#elif defined(Q_OS_MACOS)
42#elif defined(USE_INOTIFY)
46#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
48#elif defined(Q_OS_MACOS)
79 this, &QFileSystemWatcherPrivate::winDriveLockForRemoval);
81 this, &QFileSystemWatcherPrivate::winDriveLockForRemovalFailed);
83 this, &QFileSystemWatcherPrivate::winDriveRemoved);
101 qCDebug(lcWatcher) <<
"file changed" <<
path <<
"removed?" << removed <<
"watching?" <<
files.contains(
path);
108 emit q->fileChanged(
path, QFileSystemWatcher::QPrivateSignal());
121 emit q->directoryChanged(
path, QFileSystemWatcher::QPrivateSignal());
126void QFileSystemWatcherPrivate::winDriveLockForRemoval(
const QString &
path)
133 std::remove_copy_if(
files.cbegin(),
files.cend(),
134 std::back_inserter(pathsToBeRemoved), pred);
136 std::back_inserter(pathsToBeRemoved), pred);
137 if (!pathsToBeRemoved.isEmpty()) {
138 q->removePaths(pathsToBeRemoved);
139 temporarilyRemovedPaths.insert(
path.at(0), pathsToBeRemoved);
143void QFileSystemWatcherPrivate::winDriveLockForRemovalFailed(
const QString &
path)
148 if (!
path.isEmpty()) {
149 const auto it = temporarilyRemovedPaths.
find(
path.at(0));
150 if (
it != temporarilyRemovedPaths.
end()) {
151 q->addPaths(
it.value());
152 temporarilyRemovedPaths.erase(
it);
157void QFileSystemWatcherPrivate::winDriveRemoved(
const QString &
path)
161 temporarilyRemovedPaths.remove(
path.at(0));
268 if (
path.isEmpty()) {
269 qWarning(
"QFileSystemWatcher::addPath: path is empty");
274 return paths.isEmpty();
281 const auto isEmpty = [](
const QString &
s) {
return s.isEmpty(); };
282 std::remove_copy_if(
paths.begin(),
paths.end(),
283 std::back_inserter(
p),
318 qWarning(
"QFileSystemWatcher::addPaths: list is empty");
323#ifdef QT_BUILD_INTERNAL
329 if (forceName ==
"poller"_L1) {
330 qCDebug(lcWatcher,
"QFileSystemWatcher: skipping native engine, using only polling engine");
331 d_func()->initPollerEngine();
333 }
else if (forceName ==
"native"_L1) {
334 qCDebug(lcWatcher,
"QFileSystemWatcher: skipping polling engine, using only native engine");
344 d_func()->initPollerEngine();
349 if (
auto engine = selectEngine())
350 p =
engine->addPaths(
p, &
d->files, &
d->directories);
367 if (
path.isEmpty()) {
368 qWarning(
"QFileSystemWatcher::removePath: path is empty");
373 return paths.isEmpty();
394 qWarning(
"QFileSystemWatcher::removePaths: list is empty");
400 p =
d->native->removePaths(
p, &
d->files, &
d->directories);
402 p =
d->poller->removePaths(
p, &
d->files, &
d->directories);
454 return d->directories;
465#include "moc_qfilesystemwatcher.cpp"
466#include "moc_qfilesystemwatcher_p.cpp"
void directoryChanged(const QString &path, bool removed)
void fileChanged(const QString &path, bool removed)
void connectEngine(QFileSystemWatcherEngine *e)
void fileChanged(const QString &path, bool removed)
QFileSystemWatcherEngine * native
QFileSystemWatcherEngine * poller
QFileSystemWatcherPrivate()
void directoryChanged(const QString &path, bool removed)
QStringList directories() const
Returns a list of paths to directories that are being watched.
QStringList files() const
Returns a list of paths to files that are being watched.
QFileSystemWatcher(QObject *parent=nullptr)
Constructs a new file system watcher object with the given parent.
bool removePath(const QString &file)
Removes the specified path from the file system watcher.
QStringList removePaths(const QStringList &files)
Removes the specified paths from the file system watcher.
bool addPath(const QString &file)
Adds path to the file system watcher if path exists.
~QFileSystemWatcher()
Destroys the file system watcher.
QStringList addPaths(const QStringList &files)
Adds each path in paths to the file system watcher.
static QFseventsFileSystemWatcherEngine * create(QObject *parent)
static QInotifyFileSystemWatcherEngine * create(QObject *parent)
static QKqueueFileSystemWatcherEngine * create(QObject *parent)
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
QString objectName
the name of this object
iterator find(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString mid(qsizetype position, qsizetype n=-1) const &
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
static QStringList empty_paths_pruned(const QStringList &paths)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLsizei const GLuint * paths
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path