Store ExternalCommand output in QByteArray.

This makes it possible to run dd with ExternalCommand.
This commit is contained in:
Andrius Štikonas 2017-10-03 02:25:56 +01:00
parent 1fd5294184
commit 40e22c94f2
3 changed files with 9 additions and 5 deletions

View File

@ -82,7 +82,7 @@ If you only want devices from the loaded backend you can call
QList<Device*> devices = backend->scanDevices( excludeReadOnly ); QList<Device*> devices = backend->scanDevices( excludeReadOnly );
``` ```
where bool option `excludeReadOnly` specifies whether to exclude where `bool` option `excludeReadOnly` specifies whether to exclude
read only devices. read only devices.
#### KPMcore device scanner #### KPMcore device scanner

View File

@ -116,7 +116,7 @@ bool ExternalCommand::run(int timeout)
void ExternalCommand::onReadOutput() 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(m_Output.length() > 10*1024*1024) { // prevent memory overflow for badly corrupted file systems
if (report()) if (report())
@ -127,7 +127,7 @@ void ExternalCommand::onReadOutput()
m_Output += s; m_Output += s;
if (report()) if (report())
*report() << s; *report() << QString::fromLocal8Bit(s);
} }
void ExternalCommand::onFinished(int exitCode, QProcess::ExitStatus exitStatus) void ExternalCommand::onFinished(int exitCode, QProcess::ExitStatus exitStatus)

View File

@ -61,7 +61,11 @@ public:
return m_ExitCode; /**< @return the exit code */ 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 */ return m_Output; /**< @return the command output */
} }
@ -83,7 +87,7 @@ private:
QString m_Command; QString m_Command;
QStringList m_Args; QStringList m_Args;
int m_ExitCode; int m_ExitCode;
QString m_Output; QByteArray m_Output;
}; };
#endif #endif