Fix removal of trailing slash
The fsevents implementation of QFileSystemWatcher on Mac OS X tries to remove trailing slashes from the paths when calling addPaths(). If the user tries to watch "/", the path is changed to "". The fix checks whether the path is longer than 1 before removing trailing slashes. Change-Id: Iafb10e449c4f3bd600b02edbe7c549911db05048 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
11791e2a50
commit
40e3c1c2b1
@ -217,8 +217,8 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
|
|||||||
lastReceivedEvent = qMax(lastReceivedEvent, eventIds[i]);
|
lastReceivedEvent = qMax(lastReceivedEvent, eventIds[i]);
|
||||||
|
|
||||||
QString path = QFile::decodeName(eventPaths[i]);
|
QString path = QFile::decodeName(eventPaths[i]);
|
||||||
if (path.endsWith(QDir::separator()))
|
if (path.size() > 1 && path.endsWith(QDir::separator()))
|
||||||
path = path.mid(0, path.size() - 1);
|
path.chop(1);
|
||||||
|
|
||||||
if (eFlags & kFSEventStreamEventFlagMustScanSubDirs) {
|
if (eFlags & kFSEventStreamEventFlagMustScanSubDirs) {
|
||||||
DEBUG("\tmust rescan directory because of coalesced events");
|
DEBUG("\tmust rescan directory because of coalesced events");
|
||||||
@ -346,8 +346,8 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
|
auto sg = qScopeGuard([&]{ unhandled.push_back(path); });
|
||||||
QString origPath = path.normalized(QString::NormalizationForm_C);
|
QString origPath = path.normalized(QString::NormalizationForm_C);
|
||||||
QString realPath = origPath;
|
QString realPath = origPath;
|
||||||
if (realPath.endsWith(QDir::separator()))
|
if (realPath.size() > 1 && realPath.endsWith(QDir::separator()))
|
||||||
realPath = realPath.mid(0, realPath.size() - 1);
|
realPath.chop(1);
|
||||||
QString watchedPath, parentPath;
|
QString watchedPath, parentPath;
|
||||||
|
|
||||||
realPath = QFileInfo(realPath).canonicalFilePath();
|
realPath = QFileInfo(realPath).canonicalFilePath();
|
||||||
@ -437,8 +437,8 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
|
|||||||
for (const QString &origPath : paths) {
|
for (const QString &origPath : paths) {
|
||||||
auto sg = qScopeGuard([&]{ unhandled.push_back(origPath); });
|
auto sg = qScopeGuard([&]{ unhandled.push_back(origPath); });
|
||||||
QString realPath = origPath;
|
QString realPath = origPath;
|
||||||
if (realPath.endsWith(QDir::separator()))
|
if (realPath.size() > 1 && realPath.endsWith(QDir::separator()))
|
||||||
realPath = realPath.mid(0, realPath.size() - 1);
|
realPath.chop(1);
|
||||||
|
|
||||||
QFileInfo fi(realPath);
|
QFileInfo fi(realPath);
|
||||||
realPath = fi.canonicalFilePath();
|
realPath = fi.canonicalFilePath();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user