Details
-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
4.8.0, 5.0.1, 5.1.1, 5.2.0, 5.3.1, 5.8.0
-
Windows 7, Qt 4.8.0, Qt 5.X
-
7ef398e8fa7e283bf42eacfa9f0a514f6490aad2
Description
qtbug64121_diag.diff The Documentation (QFileInfo Class Reference) states that:
"On Windows, symlinks (shortcuts) are .lnk files. The reported size() is that of the symlink (not the link's target), and opening a symlink using QFile opens the .lnk file".
But the returned size is that of the target file, not the symlink file!
looking around in the source i found that in the file "qfilesystemengine_win.cpp" the function "QFileSystemEngine::fillMetaData" (l:808)
calls readLink which gets the path of the target...
This is wrong, it doesn't need to call readLink. Just use the symlink file path.
If we want information about the target we can call symLinkTarget().
line 808: change this
QFileSystemEntry fname; data.knownFlagsMask |= QFileSystemMetaData::WinLnkType; if(entry.filePath().endsWith(QLatin1String(".lnk"))) { data.entryFlags |= QFileSystemMetaData::WinLnkType; fname = QFileSystemEntry(readLink(entry)); } else { fname = entry; }
to
QFileSystemEntry fname; data.knownFlagsMask |= QFileSystemMetaData::WinLnkType; if(entry.filePath().endsWith(QLatin1String(".lnk"))) { data.entryFlags |= QFileSystemMetaData::WinLnkType; } fname = entry;
I compiled Qt with this changes and now it works as expected.
Attachments
Issue Links
- is duplicated by
-
QTBUG-77523 QFileInfo::size() reports the size of symlink target instead of the link file itself, contrary to the documentation
- Closed
- resulted in
-
QTBUG-75869 Make Qt aware of symlinks, junctions, and shortcuts on Windows
- Closed