diff options
Diffstat (limited to 'src/libs/utils/deviceshell.cpp')
-rw-r--r-- | src/libs/utils/deviceshell.cpp | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/src/libs/utils/deviceshell.cpp b/src/libs/utils/deviceshell.cpp index 8daf147ea5..5e43d02021 100644 --- a/src/libs/utils/deviceshell.cpp +++ b/src/libs/utils/deviceshell.cpp @@ -174,31 +174,11 @@ DeviceShell::~DeviceShell() * \param stdInData Data to send to the stdin of the command * \return true if the command finished with EXIT_SUCCESS(0) * - * Runs the cmd inside the internal shell process and return whether it exited with EXIT_SUCCESS + * Runs the cmd inside the internal shell process and return stdout, stderr and exit code * * Will automatically defer to the internal thread */ -bool DeviceShell::runInShell(const CommandLine &cmd, const QByteArray &stdInData) -{ - QTC_ASSERT(m_shellProcess, return false); - Q_ASSERT(QThread::currentThread() != &m_thread); - - const RunResult result = run(cmd, stdInData); - return result.exitCode == 0; -} - -/*! - * \brief DeviceShell::outputForRunInShell - * \param cmd The command to run - * \param stdInData Data to send to the stdin of the command - * \return The stdout of the command - * - * Runs a command inside the running shell and returns the stdout that was generated by it. - * - * Will automatically defer to the internal thread - */ -DeviceShell::RunResult DeviceShell::outputForRunInShell(const CommandLine &cmd, - const QByteArray &stdInData) +RunResult DeviceShell::runInShell(const CommandLine &cmd, const QByteArray &stdInData) { QTC_ASSERT(m_shellProcess, return {}); Q_ASSERT(QThread::currentThread() != &m_thread); @@ -210,7 +190,7 @@ DeviceShell::State DeviceShell::state() const { return m_shellScriptState; } QStringList DeviceShell::missingFeatures() const { return m_missingFeatures; } -DeviceShell::RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData) +RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData) { if (m_shellScriptState == State::NoScript) { // Fallback ... @@ -539,16 +519,16 @@ void DeviceShell::onReadyRead() QTC_ASSERT(itCmd != m_commandOutput.end(), continue); switch (type) { - case Utils::DeviceShell::ParseType::StdOut: + case ParseType::StdOut: itCmd->stdOut.append(data); break; - case Utils::DeviceShell::ParseType::StdErr: + case ParseType::StdErr: itCmd->stdErr.append(data); break; - case Utils::DeviceShell::ParseType::ExitCode: { + case ParseType::ExitCode: { bool ok = false; int exitCode; - exitCode = QString::fromUtf8(data.begin(), data.size()).toInt(&ok); + exitCode = data.toInt(&ok); QTC_ASSERT(ok, exitCode = -1); itCmd->exitCode = exitCode; itCmd->waiter->wakeOne(); |