forked from qt-creator/qt-creator
Utils: Consolidate the isRelative/isAbsolute implementations
Even if we do it wrong in corner cases, we should do it consistently. Change-Id: I68d5a6e55ede889cb44bedb46d0ea545dae7ba2c Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -758,27 +758,6 @@ QString FileUtils::normalizedPathName(const QString &name)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isRelativePathHelper(const QString &path, OsType osType)
|
||||
{
|
||||
if (path.startsWith('/'))
|
||||
return false;
|
||||
if (osType == OsType::OsTypeWindows) {
|
||||
if (path.startsWith('\\'))
|
||||
return false;
|
||||
// Unlike QFileInfo, this won't accept a relative path with a drive letter.
|
||||
// Such paths result in a royal mess anyway ...
|
||||
if (path.length() >= 3 && path.at(1) == ':' && path.at(0).isLetter()
|
||||
&& (path.at(2) == '/' || path.at(2) == '\\'))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileUtils::isRelativePath(const QString &path)
|
||||
{
|
||||
return isRelativePathHelper(path, HostOsInfo::hostOs());
|
||||
}
|
||||
|
||||
FilePath FileUtils::commonPath(const FilePath &oldCommonPath, const FilePath &filePath)
|
||||
{
|
||||
FilePath newCommonPath = oldCommonPath;
|
||||
|
||||
Reference in New Issue
Block a user