Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75117

UNC path starting with "//?/" is not supported

    XMLWordPrintable

    Details

    • Platform/s:
      Windows

      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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                vhilshei Volker Hilsheimer
                Reporter:
                alervd Alexander Dyagilev
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes