Utils: Make Utils::withTildeHomePath a FilePath member

Gets .osType() right in remote cases.

Change-Id: I6397996062d976d7db690c5729dd4faa1f459563
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-01-03 17:04:52 +01:00
parent 55fa109b59
commit ac9023e851
9 changed files with 51 additions and 50 deletions

View File

@@ -73,25 +73,6 @@ QTCREATOR_UTILS_EXPORT QString commonPrefix(const QStringList &strings)
return strings.at(0).left(commonLength);
}
QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path)
{
if (HostOsInfo::isWindowsHost())
return path;
if (FilePath::fromString(path).needsDevice())
return path;
static const QString homePath = QDir::homePath();
QFileInfo fi(QDir::cleanPath(path));
QString outPath = fi.absoluteFilePath();
if (outPath.startsWith(homePath))
outPath = '~' + outPath.mid(homePath.size());
else
outPath = path;
return outPath;
}
static bool validateVarName(const QString &varName)
{
return !varName.startsWith("JS:");