Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15
-
None
Description
The behavior of QFileInfo::isRoot() confuses a bit.
#include <QCoreApplication> #include <QFileInfo> #include <QDir> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); auto foo = [](const QString &path) { QFileInfo fi{path}; qDebug() << path << fi.canonicalFilePath(); qDebug() << fi.isRoot(); qDebug() << QDir(fi.canonicalFilePath()).isRoot(); }; foo("C:\\"); foo("C:\\test\\..\\"); foo("C:\\..\\"); return a.exec(); }
The output is following:
"C:\\" "C:/" true true "C:\\test\\..\\" "C:/" false true "C:\\..\\" "C:/" false true
Shall the result of QFileInfo::isRoot() for the same canonical path be the same?