Utils: Make root recognition in FilePath::fromString host agnostic

Fixes a few XFAILS and a QSKIP

Change-Id: I012d873097dfa0ea565adc4e9a2b34f6c21db9dc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-09-16 12:24:13 +02:00
parent b133197258
commit 85c899de63
3 changed files with 19 additions and 12 deletions

View File

@@ -800,13 +800,23 @@ void FilePath::setFromString(const QString &filename)
{
static const QLatin1String qtcDevSlash("__qtc_devices__/");
static const QLatin1String colonSlashSlash("://");
static const QString rootPath = QDir::rootPath();
const QChar slash('/');
const QStringView fileNameView(filename);
if (fileNameView.startsWith(rootPath, Qt::CaseInsensitive)) { // Absolute path ...
const QStringView withoutRootPath = fileNameView.mid(rootPath.size());
bool startsWithRoot = false;
int rootLength = 0;
if (fileNameView.startsWith('/')) {
startsWithRoot = true;
rootLength = 1;
} else if (fileNameView.size() > 3 && fileNameView.at(1) == ':' && fileNameView.at(2) == '/') {
// FIXME: Should we check that at(0) is actually the 'right' letter?
startsWithRoot = true;
rootLength = 3;
}
if (startsWithRoot) { // Absolute path ...
const QStringView withoutRootPath = fileNameView.mid(rootLength);
if (withoutRootPath.startsWith(qtcDevSlash)) { // Starts with "/__qtc_devices__/" ...
const QStringView withoutQtcDeviceRoot = withoutRootPath.mid(qtcDevSlash.size());