forked from qt-creator/qt-creator
Utils: Implement FilePath::writeFileContents()
Including a docker version of it. Change-Id: Ib2ac6073cc2b39818fb77a7d9d608386f9d17285 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -957,6 +957,19 @@ QByteArray FilePath::fileContents(int maxSize) const
|
||||
return f.readAll();
|
||||
}
|
||||
|
||||
bool FilePath::writeFileContents(const QByteArray &data) const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
QTC_ASSERT(s_deviceHooks.writeFileContents, return {});
|
||||
return s_deviceHooks.writeFileContents(*this, data);
|
||||
}
|
||||
|
||||
QFile file(path());
|
||||
QTC_ASSERT(file.open(QFile::WriteOnly | QFile::Truncate), return false);
|
||||
qint64 res = file.write(data);
|
||||
return res == data.size();
|
||||
}
|
||||
|
||||
bool FilePath::needsDevice() const
|
||||
{
|
||||
return !m_scheme.isEmpty();
|
||||
|
||||
Reference in New Issue
Block a user