From 9285b1e7c9406710c2028a8c2597849e7095401f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 28 Apr 2021 12:05:50 +0200 Subject: [PATCH] ProjectExplorer: Prepare IDevice to re-route file and process functions Unused for now. Change-Id: I4ae7ec0e5f4f7807ef4137e5fb5a68804d6bb124 Reviewed-by: Christian Kandeler --- .../projectexplorer/devicesupport/idevice.cpp | 92 +++++++++++++++++++ .../projectexplorer/devicesupport/idevice.h | 27 ++++++ 2 files changed, 119 insertions(+) diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index d3015b1dacc..8dbb871f90c 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -97,6 +97,7 @@ * Creates an identical copy of a device object. */ +using namespace Utils; static Utils::Id newId() { @@ -200,6 +201,97 @@ void IDevice::setAllowEmptyCommand(bool allow) d->emptyCommandAllowed = allow; } +bool IDevice::isAnyUnixDevice() const +{ + return d->osType == OsTypeLinux || d->osType == OsTypeMac || d->osType == OsTypeOtherUnix; +} + +FilePath IDevice::mapToGlobalPath(const FilePath &pathOnDevice) const +{ + return pathOnDevice; +} + +bool IDevice::handlesFile(const FilePath &filePath) const +{ + Q_UNUSED(filePath); + return false; +} + +bool IDevice::isExecutableFile(const FilePath &filePath) const +{ + Q_UNUSED(filePath); + QTC_CHECK(false); + return false; +} + +bool IDevice::isReadableFile(const FilePath &filePath) const +{ + Q_UNUSED(filePath); + QTC_CHECK(false); + return false; +} + +bool IDevice::isReadableDirectory(const FilePath &filePath) const +{ + Q_UNUSED(filePath); + QTC_CHECK(false); + return false; +} + +bool IDevice::isWritableDirectory(const FilePath &filePath) const +{ + Q_UNUSED(filePath); + QTC_CHECK(false); + return false; +} + +bool IDevice::createDirectory(const Utils::FilePath &filePath) const +{ + Q_UNUSED(filePath); + QTC_CHECK(false); + return false; +} + +QList IDevice::directoryEntries(const FilePath &filePath, + const QStringList &nameFilters, + QDir::Filters filters) const +{ + Q_UNUSED(filePath); + Q_UNUSED(nameFilters); + Q_UNUSED(filters); + QTC_CHECK(false); + return {}; +} + +QByteArray IDevice::fileContents(const FilePath &filePath, int limit) const +{ + Q_UNUSED(filePath); + Q_UNUSED(limit); + QTC_CHECK(false); + return {}; +} + +void IDevice::runProcess(QtcProcess &process) const +{ + Q_UNUSED(process); + QTC_CHECK(false); +} + +int IDevice::runSynchronously(const CommandLine &cmd, QByteArray *out, QByteArray *err) const +{ + Q_UNUSED(cmd); + Q_UNUSED(out); + Q_UNUSED(err); + QTC_CHECK(false); + return 0; +} + +Environment IDevice::systemEnvironment() const +{ + QTC_CHECK(false); + return Environment::systemEnvironment(); +} + IDevice::~IDevice() = default; /*! diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 9e046ac14ca..8dcd57c85fb 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -48,10 +49,13 @@ QT_END_NAMESPACE namespace QSsh { class SshConnectionParameters; } namespace Utils { +class CommandLine; class Environment; +class FilePath; class Icon; class PortList; class Port; +class QtcProcess; } // Utils namespace ProjectExplorer { @@ -224,6 +228,29 @@ public: bool isEmptyCommandAllowed() const; void setAllowEmptyCommand(bool allow); + bool isWindowsDevice() const { return osType() == Utils::OsTypeWindows; } + bool isLinuxDevice() const { return osType() == Utils::OsTypeLinux; } + bool isMacDevice() const { return osType() == Utils::OsTypeMac; } + bool isAnyUnixDevice() const; + + virtual Utils::FilePath mapToGlobalPath(const Utils::FilePath &pathOnDevice) const; + + virtual bool handlesFile(const Utils::FilePath &filePath) const; + virtual bool isExecutableFile(const Utils::FilePath &filePath) const; + virtual bool isReadableFile(const Utils::FilePath &filePath) const; + virtual bool isReadableDirectory(const Utils::FilePath &filePath) const; + virtual bool isWritableDirectory(const Utils::FilePath &filePath) const; + virtual bool createDirectory(const Utils::FilePath &filePath) const; + virtual QList directoryEntries(const Utils::FilePath &filePath, + const QStringList &nameFilters, + QDir::Filters filters) const; + virtual QByteArray fileContents(const Utils::FilePath &filePath, int limit) const; + virtual void runProcess(Utils::QtcProcess &process) const; + virtual int runSynchronously(const Utils::CommandLine &cmd, + QByteArray *out = nullptr, + QByteArray *err = nullptr) const; + virtual Utils::Environment systemEnvironment() const; + protected: IDevice();