forked from qt-creator/qt-creator
Utils: Drop QDir::rootPath() uses from FilePath parsing
Fixes three of the EXPECTED_FAIL. Change-Id: Idf5356cf6ff151c61166404e2b2697b6b0acabd9 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -817,27 +817,23 @@ void FilePath::setFromString(const QString &filename)
|
|||||||
const QChar slash('/');
|
const QChar slash('/');
|
||||||
const QStringView fileNameView(filename);
|
const QStringView fileNameView(filename);
|
||||||
|
|
||||||
bool startsWithRoot = false;
|
bool startsWithQtcSlashDev = false;
|
||||||
int rootLength = 0;
|
QStringView withoutQtcDeviceRoot = fileNameView;
|
||||||
if (fileNameView.startsWith('/')) {
|
if (fileNameView.startsWith('/') && fileNameView.mid(1).startsWith(qtcDevSlash)) {
|
||||||
startsWithRoot = true;
|
startsWithQtcSlashDev = true;
|
||||||
rootLength = 1;
|
withoutQtcDeviceRoot = withoutQtcDeviceRoot.mid(1 + qtcDevSlash.size());
|
||||||
} else if (fileNameView.size() > 3 && fileNameView.at(1) == ':' && fileNameView.at(2) == '/') {
|
} else if (fileNameView.size() > 3 && isWindowsDriveLetter(fileNameView.at(0))
|
||||||
// FIXME: Should we check that at(0) is actually the 'right' letter?
|
&& fileNameView.at(1) == ':' && fileNameView.mid(3).startsWith(qtcDevSlash)) {
|
||||||
startsWithRoot = true;
|
startsWithQtcSlashDev = true;
|
||||||
rootLength = 3;
|
withoutQtcDeviceRoot = withoutQtcDeviceRoot.mid(3 + qtcDevSlash.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startsWithRoot) { // Absolute path ...
|
if (startsWithQtcSlashDev) {
|
||||||
const QStringView withoutRootPath = fileNameView.mid(rootLength);
|
const int firstSlash = withoutQtcDeviceRoot.indexOf(slash);
|
||||||
if (withoutRootPath.startsWith(qtcDevSlash)) { // Starts with "/__qtc_devices__/" ...
|
|
||||||
const QStringView withoutQtcDeviceRoot = withoutRootPath.mid(qtcDevSlash.size());
|
|
||||||
|
|
||||||
const auto firstSlash = withoutQtcDeviceRoot.indexOf(slash);
|
|
||||||
|
|
||||||
if (firstSlash != -1) {
|
if (firstSlash != -1) {
|
||||||
m_scheme = withoutQtcDeviceRoot.left(firstSlash).toString();
|
m_scheme = withoutQtcDeviceRoot.left(firstSlash).toString();
|
||||||
const auto secondSlash = withoutQtcDeviceRoot.indexOf(slash, firstSlash + 1);
|
const int secondSlash = withoutQtcDeviceRoot.indexOf(slash, firstSlash + 1);
|
||||||
m_host = withoutQtcDeviceRoot.mid(firstSlash + 1, secondSlash - firstSlash - 1)
|
m_host = withoutQtcDeviceRoot.mid(firstSlash + 1, secondSlash - firstSlash - 1)
|
||||||
.toString();
|
.toString();
|
||||||
if (secondSlash != -1) {
|
if (secondSlash != -1) {
|
||||||
@@ -855,14 +851,13 @@ void FilePath::setFromString(const QString &filename)
|
|||||||
m_path = filename;
|
m_path = filename;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const auto firstSlash = filename.indexOf(slash);
|
const int firstSlash = filename.indexOf(slash);
|
||||||
const auto schemeEnd = filename.indexOf(colonSlashSlash);
|
const int schemeEnd = filename.indexOf(colonSlashSlash);
|
||||||
if (schemeEnd != -1 && schemeEnd < firstSlash) {
|
if (schemeEnd != -1 && schemeEnd < firstSlash) {
|
||||||
// This is a pseudo Url, we can't use QUrl here sadly.
|
// This is a pseudo Url, we can't use QUrl here sadly.
|
||||||
m_scheme = filename.left(schemeEnd);
|
m_scheme = filename.left(schemeEnd);
|
||||||
const auto hostEnd = filename.indexOf(slash, schemeEnd + 3);
|
const int hostEnd = filename.indexOf(slash, schemeEnd + 3);
|
||||||
m_host = filename.mid(schemeEnd + 3, hostEnd - schemeEnd - 3);
|
m_host = filename.mid(schemeEnd + 3, hostEnd - schemeEnd - 3);
|
||||||
if (hostEnd != -1)
|
if (hostEnd != -1)
|
||||||
setPath(QStringView(filename).mid(hostEnd));
|
setPath(QStringView(filename).mid(hostEnd));
|
||||||
|
Reference in New Issue
Block a user