From 40e22c94f2af089f2fd8a10435fc1c3d9262b480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Tue, 3 Oct 2017 02:25:56 +0100 Subject: [PATCH] Store ExternalCommand output in QByteArray. This makes it possible to run dd with ExternalCommand. --- README.md | 2 +- src/util/externalcommand.cpp | 4 ++-- src/util/externalcommand.h | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e82d9c..2fd29bd 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ If you only want devices from the loaded backend you can call QList devices = backend->scanDevices( excludeReadOnly ); ``` -where bool option `excludeReadOnly` specifies whether to exclude +where `bool` option `excludeReadOnly` specifies whether to exclude read only devices. #### KPMcore device scanner diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index 6e3607a..b38b1f2 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -116,7 +116,7 @@ bool ExternalCommand::run(int timeout) void ExternalCommand::onReadOutput() { - const QString s = QString::fromUtf8(readAllStandardOutput()); + const QByteArray s = readAllStandardOutput(); if(m_Output.length() > 10*1024*1024) { // prevent memory overflow for badly corrupted file systems if (report()) @@ -127,7 +127,7 @@ void ExternalCommand::onReadOutput() m_Output += s; if (report()) - *report() << s; + *report() << QString::fromLocal8Bit(s); } void ExternalCommand::onFinished(int exitCode, QProcess::ExitStatus exitStatus) diff --git a/src/util/externalcommand.h b/src/util/externalcommand.h index f9a665f..f854ee0 100644 --- a/src/util/externalcommand.h +++ b/src/util/externalcommand.h @@ -61,7 +61,11 @@ public: return m_ExitCode; /**< @return the exit code */ } - const QString& output() const { + const QString output() const { + return QString::fromLocal8Bit(m_Output); /**< @return the command output */ + } + + const QByteArray& rawOutput() const { return m_Output; /**< @return the command output */ } @@ -83,7 +87,7 @@ private: QString m_Command; QStringList m_Args; int m_ExitCode; - QString m_Output; + QByteArray m_Output; }; #endif