diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-09-28 13:56:16 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-30 23:39:54 +0000 |
commit | 520afbbbee5d5f49badc6dbf982d09ded6661bac (patch) | |
tree | e6f68ed70a7ad9b8d4bd5a85a12f40ccb62b6936 /src | |
parent | 953c3592894d9bb99a3799ee0cf06f61a1af1254 (diff) |
Fix QDir::entryList to work for directories that end with '.lnk'
In addition to checking the .lnk extension, check that the
the specified path is not a path to a directory.
Fixes: QTBUG-85058
Change-Id: I83cef3d94c6ffa82a88f374c5b41779e88fe40b8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 55ab987c9a518f217c02ca1382656ac97c53b307)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfilesystemengine_p.h | 1 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 7 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemiterator_win.cpp | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index b5daa3b88e..0b6f0fbd84 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -144,6 +144,7 @@ public: QAbstractFileEngine::FileTime whatTime, QSystemError &error); static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own); static QString nativeAbsoluteFilePath(const QString &path); + static bool isDirPath(const QString &path, bool *existed); #endif //homePath, rootPath and tempPath shall return clean paths static QString homePath(); diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 0d3dd2e0b2..33a123d6fd 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1022,8 +1022,6 @@ bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data, return data.hasFlags(what); } -static bool isDirPath(const QString &dirPath, bool *existed); - //static bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) @@ -1103,7 +1101,8 @@ static inline bool rmDir(const QString &path) return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); } -static bool isDirPath(const QString &dirPath, bool *existed) +//static +bool QFileSystemEngine::isDirPath(const QString &dirPath, bool *existed) { QString path = dirPath; if (path.length() == 2 && path.at(1) == QLatin1Char(':')) @@ -1141,7 +1140,7 @@ static bool createDirectoryWithParents(const QString &nativeName, bool shouldMkd }; const auto isDir = [](const QString &nativeName) { bool exists = false; - return isDirPath(nativeName, &exists) && exists; + return QFileSystemEngine::isDirPath(nativeName, &exists) && exists; }; // Do not try to mkdir a UNC root path or a drive letter. if (isUNCRoot(nativeName) || isDriveName(nativeName)) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 1b65ae3c09..ac52dacdce 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -59,7 +59,7 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi { Q_UNUSED(nameFilters); Q_UNUSED(flags); - if (nativePath.endsWith(QLatin1String(".lnk"))) { + if (nativePath.endsWith(u".lnk"_qs) && !QFileSystemEngine::isDirPath(dirPath, nullptr)) { QFileSystemMetaData metaData; QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData); nativePath = link.nativeFilePath(); |