Utils: Return Result from UnixDeviceFileAccess::runInShellSuccess

Change-Id: Id3fc04d08aa01f9c87831293cbd993cebd53d834
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2024-10-09 14:21:39 +02:00
parent 77635f2bab
commit ab03449fb9
2 changed files with 8 additions and 5 deletions

View File

@@ -1067,12 +1067,15 @@ static Utils::unexpected<QString> make_unexpected_disconnected()
UnixDeviceFileAccess::~UnixDeviceFileAccess() = default; UnixDeviceFileAccess::~UnixDeviceFileAccess() = default;
bool UnixDeviceFileAccess::runInShellSuccess(const CommandLine &cmdLine, Result UnixDeviceFileAccess::runInShellSuccess(const CommandLine &cmdLine,
const QByteArray &stdInData) const const QByteArray &stdInData) const
{ {
if (disconnected()) if (disconnected())
return false; return Result::Error("disconnected");
return runInShell(cmdLine, stdInData).exitCode == 0; const int retval = runInShell(cmdLine, stdInData).exitCode;
if (retval != 0)
return Result::Error(QString("return value %1").arg(retval));
return Result::Ok;
} }
bool UnixDeviceFileAccess::isExecutableFile(const FilePath &filePath) const bool UnixDeviceFileAccess::isExecutableFile(const FilePath &filePath) const

View File

@@ -144,7 +144,7 @@ public:
protected: protected:
virtual RunResult runInShell(const CommandLine &cmdLine, virtual RunResult runInShell(const CommandLine &cmdLine,
const QByteArray &inputData = {}) const = 0; const QByteArray &inputData = {}) const = 0;
bool runInShellSuccess(const CommandLine &cmdLine, const QByteArray &stdInData = {}) const; Result runInShellSuccess(const CommandLine &cmdLine, const QByteArray &stdInData = {}) const;
bool isExecutableFile(const FilePath &filePath) const override; bool isExecutableFile(const FilePath &filePath) const override;
bool isReadableFile(const FilePath &filePath) const override; bool isReadableFile(const FilePath &filePath) const override;