forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <utils/url.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
|
||||
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
|
||||
|
@@ -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<Utils::FilePath> 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();
|
||||
|
Reference in New Issue
Block a user