forked from qt-creator/qt-creator
Utils: Remove offset parameter from writeFileContents
It never worked and was not used, so remove it for now. Change-Id: If271bf83e1c766cc31fdb24dbab9eac228fda0a2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -314,12 +314,10 @@ expected_str<QByteArray> DeviceFileAccess::fileContents(const FilePath &filePath
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_str<qint64> DeviceFileAccess::writeFileContents(const FilePath &filePath,
|
expected_str<qint64> DeviceFileAccess::writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const
|
||||||
qint64 offset) const
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(filePath)
|
Q_UNUSED(filePath)
|
||||||
Q_UNUSED(data)
|
Q_UNUSED(data)
|
||||||
Q_UNUSED(offset)
|
|
||||||
QTC_CHECK(false);
|
QTC_CHECK(false);
|
||||||
return make_unexpected(
|
return make_unexpected(
|
||||||
Tr::tr("writeFileContents is not implemented for \"%1\".").arg(filePath.toUserOutput()));
|
Tr::tr("writeFileContents is not implemented for \"%1\".").arg(filePath.toUserOutput()));
|
||||||
@@ -738,8 +736,7 @@ expected_str<QByteArray> DesktopDeviceFileAccess::fileContents(const FilePath &f
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_str<qint64> DesktopDeviceFileAccess::writeFileContents(const FilePath &filePath,
|
expected_str<qint64> DesktopDeviceFileAccess::writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const
|
||||||
qint64 offset) const
|
|
||||||
{
|
{
|
||||||
QFile file(filePath.path());
|
QFile file(filePath.path());
|
||||||
const bool isOpened = file.open(QFile::WriteOnly | QFile::Truncate);
|
const bool isOpened = file.open(QFile::WriteOnly | QFile::Truncate);
|
||||||
@@ -747,8 +744,6 @@ expected_str<qint64> DesktopDeviceFileAccess::writeFileContents(const FilePath &
|
|||||||
return make_unexpected(
|
return make_unexpected(
|
||||||
Tr::tr("Could not open file \"%1\" for writing.").arg(filePath.toUserOutput()));
|
Tr::tr("Could not open file \"%1\" for writing.").arg(filePath.toUserOutput()));
|
||||||
|
|
||||||
if (offset != 0)
|
|
||||||
file.seek(offset);
|
|
||||||
qint64 res = file.write(data);
|
qint64 res = file.write(data);
|
||||||
if (res != data.size())
|
if (res != data.size())
|
||||||
return make_unexpected(
|
return make_unexpected(
|
||||||
@@ -1088,17 +1083,12 @@ expected_str<QByteArray> UnixDeviceFileAccess::fileContents(const FilePath &file
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected_str<qint64> UnixDeviceFileAccess::writeFileContents(const FilePath &filePath,
|
expected_str<qint64> UnixDeviceFileAccess::writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const
|
||||||
qint64 offset) const
|
|
||||||
{
|
{
|
||||||
if (disconnected())
|
if (disconnected())
|
||||||
return make_unexpected_disconnected();
|
return make_unexpected_disconnected();
|
||||||
|
|
||||||
QStringList args = {"of=" + filePath.path()};
|
QStringList args = {"of=" + filePath.path()};
|
||||||
if (offset != 0) {
|
|
||||||
args.append("bs=1");
|
|
||||||
args.append(QString("seek=%1").arg(offset));
|
|
||||||
}
|
|
||||||
RunResult result = runInShell({"dd", args, OsType::OsTypeLinux}, data);
|
RunResult result = runInShell({"dd", args, OsType::OsTypeLinux}, data);
|
||||||
|
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ protected:
|
|||||||
qint64 offset) const;
|
qint64 offset) const;
|
||||||
|
|
||||||
virtual expected_str<qint64> writeFileContents(const FilePath &filePath,
|
virtual expected_str<qint64> writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const;
|
||||||
qint64 offset) const;
|
|
||||||
|
|
||||||
virtual expected_str<FilePath> createTempFile(const FilePath &filePath);
|
virtual expected_str<FilePath> createTempFile(const FilePath &filePath);
|
||||||
};
|
};
|
||||||
@@ -125,8 +124,7 @@ protected:
|
|||||||
qint64 limit,
|
qint64 limit,
|
||||||
qint64 offset) const override;
|
qint64 offset) const override;
|
||||||
expected_str<qint64> writeFileContents(const FilePath &filePath,
|
expected_str<qint64> writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const override;
|
||||||
qint64 offset) const override;
|
|
||||||
|
|
||||||
expected_str<FilePath> createTempFile(const FilePath &filePath) override;
|
expected_str<FilePath> createTempFile(const FilePath &filePath) override;
|
||||||
|
|
||||||
@@ -178,8 +176,7 @@ protected:
|
|||||||
qint64 limit,
|
qint64 limit,
|
||||||
qint64 offset) const override;
|
qint64 offset) const override;
|
||||||
expected_str<qint64> writeFileContents(const FilePath &filePath,
|
expected_str<qint64> writeFileContents(const FilePath &filePath,
|
||||||
const QByteArray &data,
|
const QByteArray &data) const override;
|
||||||
qint64 offset) const override;
|
|
||||||
|
|
||||||
expected_str<FilePath> createTempFile(const FilePath &filePath) override;
|
expected_str<FilePath> createTempFile(const FilePath &filePath) override;
|
||||||
|
|
||||||
|
|||||||
@@ -655,9 +655,9 @@ bool FilePath::ensureReachable(const FilePath &other) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_str<qint64> FilePath::writeFileContents(const QByteArray &data, qint64 offset) const
|
expected_str<qint64> FilePath::writeFileContents(const QByteArray &data) const
|
||||||
{
|
{
|
||||||
return fileAccess()->writeFileContents(*this, data, offset);
|
return fileAccess()->writeFileContents(*this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStreamHandle FilePath::asyncCopy(const FilePath &target, QObject *context,
|
FileStreamHandle FilePath::asyncCopy(const FilePath &target, QObject *context,
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
FilePaths dirEntries(const FileFilter &filter, QDir::SortFlags sort = QDir::NoSort) const;
|
FilePaths dirEntries(const FileFilter &filter, QDir::SortFlags sort = QDir::NoSort) const;
|
||||||
FilePaths dirEntries(QDir::Filters filters) const;
|
FilePaths dirEntries(QDir::Filters filters) const;
|
||||||
expected_str<QByteArray> fileContents(qint64 maxSize = -1, qint64 offset = 0) const;
|
expected_str<QByteArray> fileContents(qint64 maxSize = -1, qint64 offset = 0) const;
|
||||||
expected_str<qint64> writeFileContents(const QByteArray &data, qint64 offset = 0) const;
|
expected_str<qint64> writeFileContents(const QByteArray &data) const;
|
||||||
FilePathInfo filePathInfo() const;
|
FilePathInfo filePathInfo() const;
|
||||||
|
|
||||||
[[nodiscard]] FilePath operator/(const QString &str) const;
|
[[nodiscard]] FilePath operator/(const QString &str) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user