QWinRTFileEngine: Implement setSize
Fixes: QTBUG-77132 Change-Id: Ic0410297a2215f1b7b656966cbe84b925706532f Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
parent
e24a4976be
commit
7138d6fd6b
@ -257,6 +257,29 @@ qint64 QWinRTFileEngine::size() const
|
||||
return qint64(size);
|
||||
}
|
||||
|
||||
bool QWinRTFileEngine::setSize(qint64 size)
|
||||
{
|
||||
Q_D(QWinRTFileEngine);
|
||||
if (!d->stream) {
|
||||
setError(QFileDevice::ResizeError, QLatin1String("File must be open to be resized"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size < 0) {
|
||||
setError(QFileDevice::ResizeError, QLatin1String("File size cannot be negative"));
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr = d->stream->put_Size(static_cast<quint64>(size));
|
||||
RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ResizeError, false);
|
||||
if (!flush()) {
|
||||
setError(QFileDevice::ResizeError, QLatin1String("Could not flush file"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
qint64 QWinRTFileEngine::pos() const
|
||||
{
|
||||
Q_D(const QWinRTFileEngine);
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
bool close() override;
|
||||
bool flush() override;
|
||||
qint64 size() const override;
|
||||
bool setSize(qint64 size) override;
|
||||
qint64 pos() const override;
|
||||
bool seek(qint64 pos) override;
|
||||
bool remove() override;
|
||||
|
Loading…
Reference in New Issue
Block a user