From 113a56eb0c88cdee3209dcf16af8bc51ccef080d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 14:54:47 +0100 Subject: backward compatibility fix for QFileInfo::isRoot() In the old system, QFileInfo("p:/").isRoot() would return false because the file engine first checks exists(). Assuming P: is not mounted that would return false. This change makes QFileInfo::isRoot() check the drive exists. Reviewed-By: joao --- src/corelib/io/qfileinfo.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 232a32e..5d632d3 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1018,8 +1018,20 @@ bool QFileInfo::isRoot() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; - if (d->fileEngine == 0) - return d->fileEntry.isRoot(); + if (d->fileEngine == 0) { + if (d->fileEntry.isRoot()) { +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + //the path is a drive root, but the drive may not exist + //for backward compatibility, return true only if the drive exists + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute); + return d->metaData.exists(); +#else + return true; +#endif + } + return false; + } return d->getFileFlags(QAbstractFileEngine::RootFlag); } -- cgit v0.12