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

The relativeFilePath call is error in some case

    XMLWordPrintable

Details

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

    Description

      We have the function called relativeFilePath in QDir which can returns the path to fileName relative to the directory. But, Unfortunately, it has a little problems in some cases.

      #include <QDebug>
      #include <QFile>
      #include <QFileInfo>
      #include <QDir>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
          QFile::link("../../b", "/home/alan/Desktop/b.link");
          qInfo() << QFileInfo("/home/alan/Desktop/b.link").symLinkTarget();    // result is "/home/b"  (This code is attempting to resolve to an absolute path. The function is documented as such.)
      
          QDir dir("/home/alan/Desktop/b.link");
          qInfo() << dir.relativeFilePath(QFileInfo("/home/alan/Desktop/b.link").symLinkTarget());  // result is "../../../b"  (It is not true, isn't it?)
      }
      

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            fanruijie Alan Fan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes