ProjectExplorer: Prepare IDevice to re-route file and process functions

Unused for now.

Change-Id: I4ae7ec0e5f4f7807ef4137e5fb5a68804d6bb124
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-04-28 12:05:50 +02:00
parent 2299574e82
commit 9285b1e7c9
2 changed files with 119 additions and 0 deletions

View File

@@ -97,6 +97,7 @@
* Creates an identical copy of a device object. * Creates an identical copy of a device object.
*/ */
using namespace Utils;
static Utils::Id newId() static Utils::Id newId()
{ {
@@ -200,6 +201,97 @@ void IDevice::setAllowEmptyCommand(bool allow)
d->emptyCommandAllowed = 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<FilePath> 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; IDevice::~IDevice() = default;
/*! /*!

View File

@@ -32,6 +32,7 @@
#include <QAbstractSocket> #include <QAbstractSocket>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir>
#include <QList> #include <QList>
#include <QObject> #include <QObject>
#include <QSharedPointer> #include <QSharedPointer>
@@ -48,10 +49,13 @@ QT_END_NAMESPACE
namespace QSsh { class SshConnectionParameters; } namespace QSsh { class SshConnectionParameters; }
namespace Utils { namespace Utils {
class CommandLine;
class Environment; class Environment;
class FilePath;
class Icon; class Icon;
class PortList; class PortList;
class Port; class Port;
class QtcProcess;
} // Utils } // Utils
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -224,6 +228,29 @@ public:
bool isEmptyCommandAllowed() const; bool isEmptyCommandAllowed() const;
void setAllowEmptyCommand(bool allow); 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<Utils::FilePath> 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: protected:
IDevice(); IDevice();