Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.2.0 RC
-
None
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?) }