Browse Source

Return QByteArray instead of bool in readData.

master
Andrius Štikonas 3 months ago
parent
commit
a06d4ba0f7
3 changed files with 8 additions and 6 deletions
  1. +2
    -1
      src/plugins/sfdisk/sfdiskbackend.cpp
  2. +5
    -4
      src/util/externalcommand.cpp
  3. +1
    -1
      src/util/externalcommand.h

+ 2
- 1
src/plugins/sfdisk/sfdiskbackend.cpp View File

@ -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);


+ 5
- 4
src/util/externalcommand.cpp View File

@ -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)


+ 1
- 1
src/util/externalcommand.h View File

@ -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…
Cancel
Save