Details
-
Bug
-
Resolution: Duplicate
-
P4: Low
-
None
-
5.11.1, 5.11.2
-
None
-
Windows 10
Description
QFileInfo::symLinkTarget() returns an incorrect path on a symlink for a shared folder on WindowsQFileInfo::symLinkTarget() returns an incorrect path on a symlink for a shared folder on Windows
On Windows 10, for a symbolic link created for a shared directory using "MKLINK /D", QFileInfo::symLinkTarget() returns an incorrect path. For a shortcut pointing to the symbolic link, QFileInfo::canonicalFilePath() / QFileInfo::canonicalPath() returns an incorrect path.
Steps to reproduce:
- Create a directory named as "c:\test_shared". Put some directories and text file under the ‘test_shared’ directory.
- Make the ‘test_shared’ directory as a shared directory. Go to properties of ‘test_shared’ directory, Sharing tab, Click on ‘Share…’
- Now we will have a UNC path for ‘test_shared’ directory ( UNC Path: [ https://msdn.microsoft.com/en-us/library/cc227007.aspx|https://msdn.microsoft.com/en-us/library/cc227007.aspx] ). For example for a machine named ‘foo’, the UNC path for ‘test_shared’ is ‘//foo/test_shared’
- Create a symlink on "c:\" for ‘//foo/test_shared’. Open a command prompt, and run "MKLINK /D c:\link_to_share \\foo\test_shared"
- Create a shortcut on "c:\" to ‘link_to_share’. Right click on ‘link_to_share’ and select ‘Create shortcut’. This creates ‘c:\link_to_share – Shortcut’
- Then try the following code
QString paths[2] = { QLatin1String("C:\\link_to_share"), QLatin1String("C:\\link_to_share - Shortcut.lnk") }; QFileInfo info1(paths[0]); qDebug() << info1.filePath() << info1.symLinkTarget(); QFileInfo info2(paths[1]); qDebug() << info2.filePath() << info2.canonicalFilePath();
Expected results:
"C:/link_to_share" "//foo/test_shared"
"C:/link_to_share - Shortcut.lnk" "//foo/test_shared"
Output:
"C:/link_to_share" "C:/UNC/foo/test_shared"
"C:/link_to_share - Shortcut.lnk" "C:/UNC/foo/test_shared"
Attachments
Issue Links
- duplicates
-
QTBUG-63970 QFileInfo::canonicalPath() does not works right on WIndows symlinks to UNC paths
- Closed
For Gerrit Dashboard: QTBUG-71700 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
245162,2 | QFileInfo::symLinkTarget() returns incorrect path for a symlink for a share on Windows | 5.11.3 | qt/qtbase | Status: ABANDONED | 0 | 0 |