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

The symlink target is error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.2.0 RC
    • Core: I/O
    • None
    • Linux/Wayland, Linux/X11, macOS

    Description

      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          qDebug() << QFile::link("../../a", "/tmp/a.link");
          qDebug() << QFileInfo("/tmp/a.link").symLinkTarget();
          return 0;
      }
      

      The output is:

      Output of Qt

      true
      "/../a"

      Output of 'ls -lh' command

      /tmp/a.link -> ../../a

      The expected is:

      Expected Output of Qt

      true
      "../../a"

      Yes, i have looked the document of the QFile::symLinkTarget, it's in flowing:

      QFile::symLinkTarget

      Returns the absolute path to the file or directory a symbolic link points to, or an empty string if the object isn't a symbolic link.
      This name may not represent an existing file; it is only a string. QFileInfo::exists() returns true if the symlink points to an existing file.
      This function was introduced in Qt 4.2.
      See also exists(), isSymLink(), isDir(), and isFile().

      But, i can't get the "../../a" from the "/../a", why it's returns the absolute path? How can i get the origin symlink path on Qt?

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            zccrs JiDe Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes