diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2012-01-17 12:54:28 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-17 19:55:44 (GMT) |
commit | 611eb9e5e5c8fe8035482e502b84263f43779dd8 (patch) | |
tree | 99574c94e37ad405f27e7802578489aed52899c2 /src/corelib/io | |
parent | 448ab7cd150ab7bb7d12bcac76bc2ce1c72298bd (diff) | |
download | Qt-611eb9e5e5c8fe8035482e502b84263f43779dd8.zip Qt-611eb9e5e5c8fe8035482e502b84263f43779dd8.tar.gz Qt-611eb9e5e5c8fe8035482e502b84263f43779dd8.tar.bz2 |
fix NTFS mount points
NTFS mount points are not treated as symlinks, because they might
not have a link target.
This is the case when a volume is mounted as a single mount point
without a drive letter.
This patch fixes building Qt in an NTFS mount point.
Task-number: QTBUG-20431
Change-Id: Ie2e15212e1a7ca7fa0067b7ca8857e243e42c21a
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemiterator_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemmetadata_p.h | 24 |
3 files changed, 24 insertions, 12 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 7e43684..d807d06 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -796,9 +796,10 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData & int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { WIN32_FIND_DATA findData; - if (getFindData(fname.nativeFilePath(), findData) + const QString nativeFilePath = fname.nativeFilePath(); + if (getFindData(nativeFilePath, findData) && findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES) { - data.fillFromFindData(findData, true, fname.isDriveRoot()); + data.fillFromFindData(findData, true, fname.isDriveRoot(), nativeFilePath); filledData = true; } } @@ -879,8 +880,9 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.knownFlagsMask |= QFileSystemMetaData::LinkType; if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { WIN32_FIND_DATA findData; - if (getFindData(fname.nativeFilePath(), findData)) - data.fillFromFindData(findData, true); + const QString nativeFilePath = fname.nativeFilePath(); + if (getFindData(nativeFilePath, findData)) + data.fillFromFindData(findData, true, false, nativeFilePath); } } data.knownFlagsMask |= what; diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 1f5cf35..030ef21 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -138,7 +138,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa fileEntry = QFileSystemEntry(dirPath + fileName); metaData = QFileSystemMetaData(); if (!fileName.endsWith(QLatin1String(".lnk"))) { - metaData.fillFromFindData(findData, true); + metaData.fillFromFindData(findData, true, false, fileEntry.nativeFilePath()); } return true; } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 7ee080e..f6b5a99 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -234,7 +234,7 @@ public: #if defined(Q_OS_WIN) inline void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot = false); - inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false); + inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false, const QString &nativeFullFilePath = QString()); inline void fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo); #endif private: @@ -350,7 +350,7 @@ inline void QFileSystemMetaData::fillFromFileAttribute(DWORD fileAttribute,bool knownFlagsMask |= FileType | DirectoryType | HiddenAttribute | ExistsAttribute; } -inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot) +inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot, const QString &nativeFullFilePath) { fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot); creationTime_ = findData.ftCreationTime; @@ -368,13 +368,23 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo knownFlagsMask |= LinkType; entryFlags &= ~LinkType; #if !defined(Q_OS_WINCE) - if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) - && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK - || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { - entryFlags |= LinkType; + if (fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { + if (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { + entryFlags |= LinkType; + } else if (findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT) { + // Junctions and mount points are implemented as NTFS reparse points. + // But mount points cannot be treated as symlinks because they might + // not have a link target. + wchar_t buf[50]; + QString path = nativeFullFilePath; + if (!path.endsWith(QLatin1Char('\\'))) + path.append(QLatin1Char('\\')); + BOOL isMountPoint = GetVolumeNameForVolumeMountPoint(reinterpret_cast<const wchar_t*>(path.utf16()), buf, sizeof(buf) / sizeof(wchar_t)); + if (!isMountPoint) + entryFlags |= LinkType; + } } #endif - } } |