I need to monitore a filesystem, i have a function which browse folders and files recursively and which add theirs path to my QFileSystemWatcher :
void watchFileSystem(const QDir& dir, QFileSystemWatcher& watcher)
{
watcher.addPath(dir.absolutePath());
QDirIterator iterator(dir.absolutePath(), QDirIterator::Subdirectories);
while (iterator.hasNext()) {
QString foldername = QString(iterator.fileName());
if (foldername != "." && foldername != ".." && foldername != "")
watcher.addPath(iterator.filePath());
iterator.next();
if (!iterator.fileInfo().isDir()) {
watcher.addPath(iterator.filePath());
}
}
}
While running, every "watcher.addPath(iterator.filePath());" I have this error message in the console :
QFileSystemWatcher: failed to add paths: C:/.../anyfile.ext
The strangest thing is that it works anyway. When I rename/edit a file or a folder, the fileChanged and folderChanged event is triggered.
Anyone has an idea of what is happening ? I'm worried about an instability of my program, this error can't be shown for nothing.
Thanks for reading and help,
Raphael.