From 9a03ce80bb1ed3d8e37e68881530bae122aa32a9 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 8 Jul 2021 09:37:43 +0200 Subject: [PATCH] ProjectExplorer: Implement FilePath related functions for DesktopDevice Effectively redirecting to the !needsDevice() branches in the respective FileUtils implementation. Change-Id: Ib24f1ff6fe5301323fd1296cc2ffceb0db9e4672 Reviewed-by: Christian Stenger --- .../devicesupport/desktopdevice.cpp | 98 +++++++++++++++++++ .../devicesupport/desktopdevice.h | 18 +++- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp index a11095435c1..5ee6d5b4bf4 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp @@ -43,6 +43,7 @@ #include #include +#include using namespace ProjectExplorer::Constants; using namespace Utils; @@ -194,4 +195,101 @@ Environment DesktopDevice::systemEnvironment() const return Environment::systemEnvironment(); } +bool DesktopDevice::isExecutableFile(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.isExecutableFile(); +} + +bool DesktopDevice::isReadableFile(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.isReadableFile(); +} + +bool DesktopDevice::isWritableFile(const Utils::FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.isWritableFile(); +} + +bool DesktopDevice::isReadableDirectory(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.isReadableDir(); +} + +bool DesktopDevice::isWritableDirectory(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.isWritableDir(); +} + +bool DesktopDevice::createDirectory(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.createDir(); +} + +bool DesktopDevice::exists(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.exists(); +} + +bool DesktopDevice::ensureExistingFile(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.ensureExistingFile(); +} + +bool DesktopDevice::removeFile(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.removeFile(); +} + +bool DesktopDevice::removeRecursively(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.removeRecursively(); +} + +bool DesktopDevice::copyFile(const FilePath &filePath, const FilePath &target) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + return filePath.copyFile(target); +} + +bool DesktopDevice::renameFile(const FilePath &filePath, const FilePath &target) const +{ + QTC_ASSERT(handlesFile(filePath), return false); + QTC_ASSERT(handlesFile(target), return false); + return filePath.renameFile(target); +} + +QDateTime DesktopDevice::lastModified(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return {}); + return filePath.lastModified(); +} + +FilePath DesktopDevice::symLinkTarget(const FilePath &filePath) const +{ + QTC_ASSERT(handlesFile(filePath), return {}); + return filePath.symLinkTarget(); +} + +QByteArray DesktopDevice::fileContents(const FilePath &filePath, int limit) const +{ + QTC_ASSERT(handlesFile(filePath), return {}); + return filePath.fileContents(limit); +} + +bool DesktopDevice::writeFileContents(const Utils::FilePath &filePath, const QByteArray &data) const +{ + QTC_ASSERT(handlesFile(filePath), return {}); + return filePath.writeFileContents(data); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.h b/src/plugins/projectexplorer/devicesupport/desktopdevice.h index 9c1aac3af1f..a1a5379f00f 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.h @@ -54,13 +54,29 @@ public: DeviceProcessSignalOperation::Ptr signalOperation() const override; DeviceEnvironmentFetcher::Ptr environmentFetcher() const override; QUrl toolControlChannel(const ControlChannelHint &) const override; + bool handlesFile(const Utils::FilePath &filePath) const override; QList directoryEntries(const Utils::FilePath &filePath, const QStringList &nameFilters, QDir::Filters filters, QDir::SortFlags sort) const override; Utils::Environment systemEnvironment() const override; - + bool isExecutableFile(const Utils::FilePath &filePath) const override; + bool isReadableFile(const Utils::FilePath &filePath) const override; + bool isWritableFile(const Utils::FilePath &filePath) const override; + bool isReadableDirectory(const Utils::FilePath &filePath) const override; + bool isWritableDirectory(const Utils::FilePath &filePath) const override; + bool ensureExistingFile(const Utils::FilePath &filePath) const override; + bool createDirectory(const Utils::FilePath &filePath) const override; + bool exists(const Utils::FilePath &filePath) const override; + bool removeFile(const Utils::FilePath &filePath) const override; + bool removeRecursively(const Utils::FilePath &filePath) const override; + bool copyFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override; + bool renameFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override; + QDateTime lastModified(const Utils::FilePath &filePath) const override; + Utils::FilePath symLinkTarget(const Utils::FilePath &filePath) const override; + QByteArray fileContents(const Utils::FilePath &filePath, int limit) const override; + bool writeFileContents(const Utils::FilePath &filePath, const QByteArray &data) const override; protected: DesktopDevice();