From 4ba07d05c4ebed82821b4a5be4f521d0b012914c Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 1 Jul 2021 11:31:30 +0200 Subject: [PATCH] Utils: Make a FilePath's osType publicly accessible Will help with proper is{Relative,Absolute}Path implementations. Change-Id: Icad90b5a55d9cf733f6ee66dbbe273ec9682d387 Reviewed-by: David Schulz --- src/libs/utils/fileutils.cpp | 18 ++++++++++-------- src/libs/utils/fileutils.h | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 374f495dfd2..c1dd491bd99 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -1011,15 +1011,8 @@ FilePath FilePath::symLinkTarget() const FilePath FilePath::withExecutableSuffix() const { - OsType osType; - if (needsDevice()) { - QTC_ASSERT(s_deviceHooks.osType, return {}); - osType = s_deviceHooks.osType(*this); - } else { - osType = HostOsInfo::hostOs(); - } FilePath res = *this; - res.setPath(OsSpecificAspects::withExecutableSuffix(osType, m_data)); + res.setPath(OsSpecificAspects::withExecutableSuffix(osType(), m_data)); return res; } @@ -1427,6 +1420,15 @@ QFile::Permissions FilePath::permissions() const return toFileInfo().permissions(); } +OsType FilePath::osType() const +{ + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.osType, return {}); + return s_deviceHooks.osType(*this); + } + return HostOsInfo::hostOs(); +} + bool FilePath::removeFile() const { if (needsDevice()) { diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index ae77ac507db..b08974009fe 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -174,6 +174,7 @@ public: bool isNewerThan(const QDateTime &timeStamp) const; QDateTime lastModified() const; QFile::Permissions permissions() const; + OsType osType() const; bool removeFile() const; bool removeRecursively(QString *error = nullptr) const; bool copyFile(const FilePath &target) const;