From ab03449fb969b0f6d7e51c5f1fbaf5d57b3dfd78 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 9 Oct 2024 14:21:39 +0200 Subject: [PATCH] Utils: Return Result from UnixDeviceFileAccess::runInShellSuccess Change-Id: Id3fc04d08aa01f9c87831293cbd993cebd53d834 Reviewed-by: Marcus Tillmanns --- src/libs/utils/devicefileaccess.cpp | 11 +++++++---- src/libs/utils/devicefileaccess.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index e318cc7df0a..4d77295363c 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -1067,12 +1067,15 @@ static Utils::unexpected make_unexpected_disconnected() UnixDeviceFileAccess::~UnixDeviceFileAccess() = default; -bool UnixDeviceFileAccess::runInShellSuccess(const CommandLine &cmdLine, - const QByteArray &stdInData) const +Result UnixDeviceFileAccess::runInShellSuccess(const CommandLine &cmdLine, + const QByteArray &stdInData) const { if (disconnected()) - return false; - return runInShell(cmdLine, stdInData).exitCode == 0; + return Result::Error("disconnected"); + 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 diff --git a/src/libs/utils/devicefileaccess.h b/src/libs/utils/devicefileaccess.h index d5c82a0076c..0b56a679dec 100644 --- a/src/libs/utils/devicefileaccess.h +++ b/src/libs/utils/devicefileaccess.h @@ -144,7 +144,7 @@ public: protected: virtual RunResult runInShell(const CommandLine &cmdLine, 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 isReadableFile(const FilePath &filePath) const override;