Utils: Use QtcProcess in FilePath::fileContents

Change-Id: Ia7236632c6d9b887d054a3254762b7e3592e73e1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-02-02 14:08:29 +01:00
parent 8096b9f524
commit 96185ca4f1

View File

@@ -960,14 +960,20 @@ expected_str<QByteArray> UnixDeviceFileAccess::fileContents(const FilePath &file
args += QString("count=%1").arg(limit / gcd); args += QString("count=%1").arg(limit / gcd);
args += QString("seek=%1").arg(offset / gcd); args += QString("seek=%1").arg(offset / gcd);
} }
#ifndef UTILS_STATIC_LIBRARY
const FilePath dd = filePath.withNewPath("dd");
const RunResult r = runInShell({"dd", args, OsType::OsTypeLinux}); QtcProcess p;
p.setCommand({dd, args, OsType::OsTypeLinux});
if (r.exitCode != 0) p.runBlocking();
if (p.exitCode() != 0) {
return make_unexpected(Tr::tr("Failed reading file \"%1\": %2") return make_unexpected(Tr::tr("Failed reading file \"%1\": %2")
.arg(filePath.toUserOutput(), QString::fromUtf8(r.stdErr))); .arg(filePath.toUserOutput(), p.readAllStandardError()));
}
return r.stdOut; return p.readAllRawStandardOutput();
#else
return make_unexpected(QString("Not implemented"));
#endif
} }
expected_str<qint64> UnixDeviceFileAccess::writeFileContents(const FilePath &filePath, expected_str<qint64> UnixDeviceFileAccess::writeFileContents(const FilePath &filePath,