diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-09-09 13:54:47 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-09-09 16:10:44 (GMT) |
commit | 113a56eb0c88cdee3209dcf16af8bc51ccef080d (patch) | |
tree | cccce1e779f78518015387dc913cb80966eba42f | |
parent | 5baa2d0da807ec5b4635c891ec27125769bade2d (diff) | |
download | Qt-113a56eb0c88cdee3209dcf16af8bc51ccef080d.zip Qt-113a56eb0c88cdee3209dcf16af8bc51ccef080d.tar.gz Qt-113a56eb0c88cdee3209dcf16af8bc51ccef080d.tar.bz2 |
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
-rw-r--r-- | src/corelib/io/qfileinfo.cpp | 16 |
1 files 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); } |