From 25960ef75f7dd9bf78fae37177ab2cdbd825af9b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 18 Jan 2012 14:01:57 +0100 Subject: Revert "fix NTFS mount points" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We agreed on treating neither junctions nor mount points as symlinks. This will be handled in another commit. This reverts commit 611eb9e5e5c8fe8035482e502b84263f43779dd8. Change-Id: I19f0bd841c7e6dd6e65e5c8df4bdfa1d6f08ce28 Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_win.cpp | 10 ++++------ src/corelib/io/qfilesystemiterator_win.cpp | 2 +- src/corelib/io/qfilesystemmetadata_p.h | 24 +++++++----------------- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index d807d06..7e43684 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -796,10 +796,9 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData & int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { WIN32_FIND_DATA findData; - const QString nativeFilePath = fname.nativeFilePath(); - if (getFindData(nativeFilePath, findData) + if (getFindData(fname.nativeFilePath(), findData) && findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES) { - data.fillFromFindData(findData, true, fname.isDriveRoot(), nativeFilePath); + data.fillFromFindData(findData, true, fname.isDriveRoot()); filledData = true; } } @@ -880,9 +879,8 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.knownFlagsMask |= QFileSystemMetaData::LinkType; if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { WIN32_FIND_DATA findData; - const QString nativeFilePath = fname.nativeFilePath(); - if (getFindData(nativeFilePath, findData)) - data.fillFromFindData(findData, true, false, nativeFilePath); + if (getFindData(fname.nativeFilePath(), findData)) + data.fillFromFindData(findData, true); } } data.knownFlagsMask |= what; diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 030ef21..1f5cf35 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, false, fileEntry.nativeFilePath()); + metaData.fillFromFindData(findData, true); } return true; } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index f6b5a99..7ee080e 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, const QString &nativeFullFilePath = QString()); + inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false); 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, const QString &nativeFullFilePath) +inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot) { fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot); creationTime_ = findData.ftCreationTime; @@ -368,23 +368,13 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo knownFlagsMask |= LinkType; entryFlags &= ~LinkType; #if !defined(Q_OS_WINCE) - 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(path.utf16()), buf, sizeof(buf) / sizeof(wchar_t)); - if (!isMountPoint) - entryFlags |= LinkType; - } + if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) + && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK + || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { + entryFlags |= LinkType; } #endif + } } diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index e36cc57..a8a510a 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1463,7 +1463,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() junction = "mountpoint"; rootVolume.replace("\\\\?\\","\\??\\"); FileSystem::createNtfsJunction(rootVolume, junction); - QTest::newRow("mountpoint") << junction << false << QString() << QFileInfo("mountpoint").canonicalFilePath(); + QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); } } -- cgit v0.12