diff options
author | David Schulz <[email protected]> | 2021-06-08 13:51:34 +0200 |
---|---|---|
committer | David Schulz <[email protected]> | 2021-06-10 11:47:14 +0000 |
commit | 4465fd06ae165d02ecc4ce706a8609a0950d30f1 (patch) | |
tree | 8f32d22b615cf3a92584a0b7efe23d733ad4caa6 /src/libs/utils/fileutils.cpp | |
parent | 62cf12737674a26bc60f12e996fcd0a542fdf297 (diff) |
Utils: add home FilePath convenience function
Change-Id: I5d0d695dc127090be4323fac6ff4ef2b1729cb92
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index e1dfaea69db..61aff9d6932 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -291,7 +291,7 @@ bool FilePath::isEmpty() const QString FilePath::shortNativePath() const { if (HostOsInfo::isAnyUnixHost()) { - const FilePath home = FilePath::fromString(QDir::cleanPath(QDir::homePath())); + const FilePath home = FileUtils::homePath(); if (isChildOf(home)) { return QLatin1Char('~') + QDir::separator() + QDir::toNativeSeparators(relativeChildPath(home).toString()); @@ -468,6 +468,11 @@ QByteArray FileUtils::fileId(const FilePath &fileName) return result; } +FilePath FileUtils::homePath() +{ + return FilePath::fromString(QDir::cleanPath(QDir::homePath())); +} + QByteArray FileReader::fetchQrc(const QString &fileName) { QTC_ASSERT(fileName.startsWith(':'), return QByteArray()); @@ -1048,7 +1053,7 @@ FilePath FilePath::fromUserInput(const QString &filePath) { QString clean = QDir::fromNativeSeparators(filePath); if (clean.startsWith(QLatin1String("~/"))) - clean = QDir::homePath() + clean.mid(1); + return FileUtils::homePath().pathAppended(clean.mid(2)); return FilePath::fromString(clean); } |