Details
-
User Story
-
Resolution: Done
-
P2: Important
-
5.12.1
-
Windows 10
Description
Windows will start an application associated with a file type by passing the file path when the user double-clicks on the respective's file icon. If that path that has a path length > MAX_PATH, (the icon's parent folder path length must be <= 247 chars), then the file path will start with the Windows-specific marker for a "long path", ie. "\\?\C:\foo\bar\....".
Qt doesn't remove this marker, and instead interprets it literally, making all file operations fail. As Qt does accept platform specific file paths (ie on Windows it's ok to feed a filename with backslashes to Qt APIs, which then converts them to slashes for all internal purposes), Qt could also automatically strip the "\\?\" prefix from apparently native paths.
QFile f("//?/D:/f.dat"); f.open(QFile::ReadWrite); // fails //win32 api succeeds ::CreateFile(L"\\\\?\\D:\\f.dat", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
This can probably be implemented in QDir::fromNativeSeparators.
The inverse should not happen: QDir::toNativeSeparators should never prepend the long-path markers, as the result of this function is often used to display native-style filenames to end users, who should never see the "\\?\" prefix. Applications that want to use native APIs to operate on file paths need to take care of adding such a prefix themselves, as appropriate.
Attachments
Issue Links
- is required for
-
QTBUG-75129 Rationalize handling of UNC paths on Windows
- Closed
For Gerrit Dashboard: QTBUG-75117 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
267513,4 | QDir: strip Windows' long-path markers when converting from native | dev | qt/qtbase | Status: MERGED | +2 | 0 |