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

Windows: QDir::entryList doesn't work for directories that end with '.lnk'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.0
    • Fix Version/s: None
    • Component/s: Core: I/O
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      Qt does contain special code paths to resolve .lnk files. Anyhow, some of the code also does apply to directories that end with '.lnk', which is dubious.

      This shows if you try to list the content of a directory whose name ends with '.lnk' via QDir::entryList, QDir::entryInfoList: Even if a file or sub-directory exists the content will be shown empty:

          // create dir
          QString lnkDirPath = parentDir.absoluteFilePath("foo.lnk");
          QDir lnkDir = parentDir.filePath(lnkDirPath);
          Q_ASSERT(lnkDir.exists());
      
          // create file
          QFile f(lnkDir.absoluteFilePath("file.txt"));
          if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
              return 1;
          f.close();
      
          // check if dir lists file
          auto entryList = lnkDir.entryInfoList();
          Q_ASSERT(entryList.size() == 1); // <<<<< asserts
          Q_ASSERT(entryList.first().fileName() == "file.txt");
      

      I'd expect that directories whose name end with '.lnk' are not treated in any way different than normal directories.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              kkohne Kai Köhne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes