forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/11.0'
Change-Id: Idbf5f641aa9db7574cf2a4bd09adb8bcd03da894
This commit is contained in:
@@ -204,7 +204,27 @@ FilePath FilePath::currentWorkingPath()
|
||||
|
||||
bool FilePath::isRootPath() const
|
||||
{
|
||||
// FIXME: Make host-independent
|
||||
if (needsDevice()) {
|
||||
QStringView path = pathView();
|
||||
if (osType() != OsTypeWindows)
|
||||
return path == QLatin1String("/");
|
||||
|
||||
// Remote windows paths look like this: "/c:/", so we remove the leading '/'
|
||||
if (path.startsWith('/'))
|
||||
path = path.mid(1);
|
||||
|
||||
if (path.length() > 3)
|
||||
return false;
|
||||
|
||||
if (!startsWithDriveLetter())
|
||||
return false;
|
||||
|
||||
if (path.length() == 3 && path[2] != QLatin1Char('/'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return *this == FilePath::fromString(QDir::rootPath());
|
||||
}
|
||||
|
||||
@@ -1383,15 +1403,15 @@ bool FilePath::contains(const QString &s) const
|
||||
|
||||
/*!
|
||||
\brief Checks whether the FilePath starts with a drive letter.
|
||||
|
||||
Defaults to \c false if it is a non-Windows host or represents a path on device
|
||||
|
||||
Returns whether FilePath starts with a drive letter
|
||||
*/
|
||||
bool FilePath::startsWithDriveLetter() const
|
||||
{
|
||||
const QStringView p = pathView();
|
||||
return !needsDevice() && p.size() >= 2 && isWindowsDriveLetter(p[0]) && p.at(1) == ':';
|
||||
QStringView p = pathView();
|
||||
if (needsDevice() && !p.isEmpty())
|
||||
p = p.mid(1);
|
||||
|
||||
return p.size() >= 2 && isWindowsDriveLetter(p[0]) && p.at(1) == ':';
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user