FilePath: Fix parsing of qrc paths

Change-Id: I50d404bafb8d1cb4f0663cd424e1034ae26bb903
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-08-08 09:17:50 +02:00
parent 3af72077a0
commit aeb33310cb
2 changed files with 11 additions and 2 deletions

View File

@@ -821,8 +821,13 @@ void FilePath::setRootAndPath(QStringView path, OsType osType)
m_root = "/";
m_path = path.mid(1).toString();
} else if (path.startsWith(':')) {
if (path.length() > 1 && path[1] == '/') {
m_root = ":/";
m_path = path.mid(2).toString();
} else {
m_root = ":";
m_path = path.mid(1).toString();
}
} else {
m_root.clear();
m_path = path.toString();

View File

@@ -350,6 +350,10 @@ void tst_fileutils::fromString_data()
QTest::addColumn<OsType>("osType");
QTest::newRow("empty") << "" << "" << "" << "" << HostOsInfo::hostOs();
QTest::newRow("single-slash") << ":" << "" << "" << ":" << HostOsInfo::hostOs();
QTest::newRow("single-colon") << "/" << "" << "" << "/" << HostOsInfo::hostOs();
QTest::newRow("single-char") << "a" << "" << "" << "a" << HostOsInfo::hostOs();
QTest::newRow("qrc-no-slash") << ":test.txt" << "" << "" << ":test.txt" << HostOsInfo::hostOs();
QTest::newRow("qrc") << ":/test.txt" << "" << "" << ":/test.txt" << HostOsInfo::hostOs();
QTest::newRow("unc-incomplete") << "//" << "" << "" << "" << OsType::OsTypeWindows;
QTest::newRow("unc-incomplete-only-server") << "//server" << "" << "" << "//server/" << OsType::OsTypeWindows;