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

QFileInfo::isSymLink does not check the object existance, whereas isFile and isDir does

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.7.0
    • Core: I/O
    • None

    Description

      Simple test scenario:

      const QString testFile{"c:\file.txt"};
      const QString testLink{"c:\linkfile.lnk"};
      
      //Note: above files do not exist.
      
      QFileInfo fileInfoLink{testLink};
      //fileInfoLink.isSymLink() == true 
      //fileInfoLink.isDir() == false
      //fileInfoLink.isFile() == false
      //QFileInfo::exists(testLink)  == false
      
      QFileInfo fileInfo{testFile};
      //fileInfo.isSymLink() == false
      //fileInfo.isDir() == false
      //fileInfo.isFile() == false
      //QFileInfo::exists(testFile)  == false
      

      So, it seems, that isSymLink only checks the name of the object (on windows, if it has ".lnk" extension), whereas isDir and isFile also check existance.

      I know, that QFileInfo::exists() returns false, if the target of the symlink does not exists. But then, maybe isSymLink() should also return false in below scenarios:

      • symlink does not exist
      • target of the symlink does not exist

      Right now, I do not see a way of checking if the symlink exists and if the symlink points to existing file.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            sikor sikor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes