Utils: Make a FilePath's osType publicly accessible

Will help with proper is{Relative,Absolute}Path implementations.

Change-Id: Icad90b5a55d9cf733f6ee66dbbe273ec9682d387
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-07-01 11:31:30 +02:00
parent 1db9dd058e
commit 4ba07d05c4
2 changed files with 11 additions and 8 deletions

View File

@@ -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()) {

View File

@@ -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;