QFileSystemEngine/Win: only .lnk files that exist can be symlinks
Fortunately, isDirPath() had an extra parameter to tell us whether the path existed in the first place, making the fix very simple. Pick-to: 6.7 6.5 Fixes: QTBUG-128800 Change-Id: I81482f87b594933158d0fffdbea0ea2a00494b6c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 329b05739d5d62f37464a5714ad87e7ca05693e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
16571ac456
commit
23cf29ffdd
@ -1390,7 +1390,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
|
||||
// Check for ".lnk": Directories named ".lnk" should be skipped, corrupted
|
||||
// link files should still be detected as links.
|
||||
const QString origFilePath = entry.filePath();
|
||||
if (origFilePath.endsWith(".lnk"_L1) && !isDirPath(origFilePath, nullptr)) {
|
||||
if (bool exists; origFilePath.endsWith(".lnk"_L1) && !isDirPath(origFilePath, &exists) && exists) {
|
||||
data.entryFlags |= QFileSystemMetaData::WinLnkType;
|
||||
fname = QFileSystemEntry(readLink(entry));
|
||||
} else {
|
||||
|
@ -1289,6 +1289,7 @@ void tst_QFileInfo::isSymLink_data()
|
||||
QTest::newRow("existent file") << m_sourceFile << false << "";
|
||||
QTest::newRow("link") << "link.lnk" << true << QFileInfo(m_sourceFile).absoluteFilePath();
|
||||
QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath();
|
||||
QTest::newRow("nonexistent") << "thispathdoesntexist.lnk" << false << QString();
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QDir::current().mkdir("relative");
|
||||
@ -1414,6 +1415,8 @@ void tst_QFileInfo::isSymbolicLink_data()
|
||||
<< regularFile.fileName() << false;
|
||||
QTest::newRow("directory")
|
||||
<< QDir::currentPath() << false;
|
||||
QTest::newRow("nonexistent")
|
||||
<< "thispathdoesntexist.lnk" << false;
|
||||
|
||||
#ifndef Q_NO_SYMLINKS
|
||||
#if defined(Q_OS_WIN)
|
||||
|
Loading…
x
Reference in New Issue
Block a user