45 #ifndef QT_NO_FILESYSTEMWATCHER 85 QMutableListIterator<QString>
it(p);
86 while (it.hasNext()) {
92 && normalPath.
size() > 1)
98 if (!fileInfo.exists())
101 bool isDir = fileInfo.
isDir();
112 const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath();
113 const uint flags = isDir
114 ? (FILE_NOTIFY_CHANGE_DIR_NAME
115 | FILE_NOTIFY_CHANGE_FILE_NAME)
116 : (FILE_NOTIFY_CHANGE_DIR_NAME
117 | FILE_NOTIFY_CHANGE_FILE_NAME
118 | FILE_NOTIFY_CHANGE_ATTRIBUTES
119 | FILE_NOTIFY_CHANGE_SIZE
120 | FILE_NOTIFY_CHANGE_LAST_WRITE
121 | FILE_NOTIFY_CHANGE_SECURITY);
125 pathInfo.
isDir = isDir;
126 pathInfo.
path = path;
139 if (handle.
handle != INVALID_HANDLE_VALUE && handle.
flags == flags) {
145 if (!h.
contains(fileInfo.absoluteFilePath())) {
148 directories->
append(path);
159 if (handle.
handle == INVALID_HANDLE_VALUE || handle.
flags != flags) {
163 const QString effectiveAbsolutePath =
164 isDir ? (absolutePath +
QLatin1Char(
'/')) : absolutePath;
167 handle.
flags = flags;
168 if (handle.
handle == INVALID_HANDLE_VALUE)
183 directories->
append(path);
201 directories->
append(path);
226 QMutableListIterator<QString>
it(p);
227 while (it.hasNext()) {
234 QString absolutePath = fileInfo.absoluteFilePath();
245 if (handle.
handle == INVALID_HANDLE_VALUE) {
247 absolutePath = fileInfo.absolutePath();
250 if (handle.
handle != INVALID_HANDLE_VALUE) {
253 if (h.
remove(fileInfo.absoluteFilePath())) {
260 FindCloseChangeNotification(handle.
handle);
292 if (!(*jt)->isRunning()) {
309 if (
HANDLE h = CreateEvent(0,
false,
false, 0)) {
320 handles[0] = INVALID_HANDLE_VALUE;
322 foreach (
HANDLE h, handles) {
323 if (h == INVALID_HANDLE_VALUE)
325 FindCloseChangeNotification(h);
336 DWORD r = WaitForMultipleObjects(handlesCopy.
count(), handlesCopy.
constData(),
false, INFINITE);
347 qDebug(
"QWindowsFileSystemWatcherEngine: unknown message '%c' send to thread",
char(m));
359 if (!FindNextChangeNotification(handle)) {
360 qErrnoWarning(
"QFileSystemWatcher: FindNextChangeNotification failed!!");
364 QMutableHashIterator<QString, QWindowsFileSystemWatcherEngine::PathInfo>
it(h);
365 while (it.hasNext()) {
370 if (!fileInfo.exists()) {
381 FindCloseChangeNotification(handle);
393 x.
value() = fileInfo;
394 }
else if (x.
value() != fileInfo) {
397 x.
value() = fileInfo;
406 r = WaitForMultipleObjects(handlesCopy.
count(), handlesCopy.
constData(),
false, 0);
407 }
while (r != WAIT_TIMEOUT);
425 #endif // QT_NO_FILESYSTEMWATCHER QList< QWindowsFileSystemWatcherEngineThread * > threads
void fileChanged(const QString &path, bool removed)
#define QT_END_NAMESPACE
This macro expands to.
int remove(const Key &key)
Removes all the items that have the key from the hash.
void remove(int i)
Removes the element at index position i.
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
#define at(className, varName)
void chop(int n)
Removes n characters from the end of the string.
void unlock()
Unlocks this mutex locker.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
~QWindowsFileSystemWatcherEngineThread()
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
const T value(const Key &key) const
Returns the value associated with the key.
QHash< QString, QWindowsFileSystemWatcherEngine::Handle > handleForDir
bool isEmpty() const
Returns true if the list 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.
void relock()
Relocks an unlocked mutex locker.
QVector< HANDLE > handles
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
int size() const
Returns the number of characters in this string.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
QWindowsFileSystemWatcherEngineThread()
The QStringList class provides a list of strings.
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
void append(const T &t)
Inserts value at the end of the vector.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories)
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the vector, searching forward from ind...
void directoryChanged(const QString &path, bool removed)
const T & at(int i) const
Returns the item at index position i in the vector.
QWindowsFileSystemWatcherEngine()
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
void fileChanged(const QString &path, bool removed)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QHash< HANDLE, QHash< QString, QWindowsFileSystemWatcherEngine::PathInfo > > pathInfoForHandle
void start(Priority=InheritPriority)
Begins execution of the thread by calling run().
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
void run()
The starting point for the thread.
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
void directoryChanged(const QString &path, bool removed)
const T * constData() const
Returns a const pointer to the data stored in the vector.
void reserve(int size)
Attempts to allocate memory for at least size elements.
QThread * thread() const
Returns the thread in which the object lives.
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories)
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
The QFileInfo class provides system-independent file information.
static const KeyPair *const end
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the '/' separators converted to separators that are appropriate for the underly...
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
~QWindowsFileSystemWatcherEngine()
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
void qErrnoWarning(const char *msg,...)
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
#define forever
This macro is provided for convenience for writing infinite loops.