Return QByteArray instead of bool in readData.
This commit is contained in:
parent
73da1bc514
commit
a06d4ba0f7
|
@ -454,7 +454,8 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
|
|||
CopySourceDevice source(d, 512, 1023);
|
||||
|
||||
ExternalCommand readCmd;
|
||||
if (readCmd.readData(source, gptHeader)) {
|
||||
gptHeader = readCmd.readData(source);
|
||||
if (gptHeader != QByteArray()) {
|
||||
QByteArray gptMaxEntries = gptHeader.mid(80, 4);
|
||||
QDataStream stream(&gptMaxEntries, QIODevice::ReadOnly);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
|
|
@ -187,17 +187,18 @@ bool ExternalCommand::copyBlocks(const CopySource& source, CopyTarget& target)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool ExternalCommand::readData(const CopySourceDevice& source, QByteArray& target)
|
||||
QByteArray ExternalCommand::readData(const CopySourceDevice& source)
|
||||
{
|
||||
auto interface = helperInterface();
|
||||
if (!interface)
|
||||
return false;
|
||||
return {};
|
||||
|
||||
QDBusPendingCall pcall = interface->ReadData(source.path(), source.firstByte(), source.length());
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
QEventLoop loop;
|
||||
|
||||
QEventLoop loop;
|
||||
QByteArray target;
|
||||
auto exitLoop = [&] (QDBusPendingCallWatcher *watcher) {
|
||||
loop.exit();
|
||||
|
||||
|
@ -213,7 +214,7 @@ bool ExternalCommand::readData(const CopySourceDevice& source, QByteArray& targe
|
|||
connect(watcher, &QDBusPendingCallWatcher::finished, exitLoop);
|
||||
loop.exec();
|
||||
|
||||
return target != QByteArray();
|
||||
return target;
|
||||
}
|
||||
|
||||
bool ExternalCommand::writeData(Report& commandReport, const QByteArray& buffer, const QString& deviceNode, const quint64 firstByte)
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
public:
|
||||
bool copyBlocks(const CopySource& source, CopyTarget& target);
|
||||
bool readData(const CopySourceDevice& source, QByteArray& target);
|
||||
QByteArray readData(const CopySourceDevice& source);
|
||||
bool writeData(Report& commandReport, const QByteArray& buffer, const QString& deviceNode, const quint64 firstByte); // same as copyBlocks but from QByteArray
|
||||
bool createFile(const QByteArray& filePath, const QString& fileContents); // similar to writeData but creates a new file
|
||||
|
||||
|
|
Loading…
Reference in New Issue