forked from qt-creator/qt-creator
Utils: Shortcut File reading
If the device can point us to the local equivalent of a file we can read that one instead. Change-Id: I002b5babae13677d5814b639ca40a62f23a8b374 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1059,6 +1059,10 @@ expected_str<QByteArray> UnixDeviceFileAccess::fileContents(const FilePath &file
|
|||||||
if (disconnected())
|
if (disconnected())
|
||||||
return make_unexpected_disconnected();
|
return make_unexpected_disconnected();
|
||||||
|
|
||||||
|
expected_str<FilePath> localSource = filePath.localSource();
|
||||||
|
if (localSource && *localSource != filePath)
|
||||||
|
return localSource->fileContents(limit, offset);
|
||||||
|
|
||||||
QStringList args = {"if=" + filePath.path()};
|
QStringList args = {"if=" + filePath.path()};
|
||||||
if (limit > 0 || offset > 0) {
|
if (limit > 0 || offset > 0) {
|
||||||
const qint64 gcd = std::gcd(limit, offset);
|
const qint64 gcd = std::gcd(limit, offset);
|
||||||
@@ -1088,6 +1092,10 @@ expected_str<qint64> UnixDeviceFileAccess::writeFileContents(const FilePath &fil
|
|||||||
if (disconnected())
|
if (disconnected())
|
||||||
return make_unexpected_disconnected();
|
return make_unexpected_disconnected();
|
||||||
|
|
||||||
|
expected_str<FilePath> localSource = filePath.localSource();
|
||||||
|
if (localSource && *localSource != filePath)
|
||||||
|
return localSource->writeFileContents(data);
|
||||||
|
|
||||||
QStringList args = {"of=" + filePath.path()};
|
QStringList args = {"of=" + filePath.path()};
|
||||||
RunResult result = runInShell({"dd", args, OsType::OsTypeLinux}, data);
|
RunResult result = runInShell({"dd", args, OsType::OsTypeLinux}, data);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user