[Interest] QFile::write(const QByteArray&) does not write, all data?

Thiago Macieira thiago.macieira at intel.com
Sat May 12 19:08:47 CEST 2018


On Saturday, 12 May 2018 07:18:03 PDT Roland Hughes wrote:
> On 05/12/2018 08:57 AM, interest-request at qt-project.org wrote:
> > On Thursday, 10 May 2018 23:11:04 PDT alexander golks wrote:
> >> i think it "silently" breaks here without setting error condition on the
> >> QFile when hitting errors on all chunks but the first one, thus returning
> >> a
> >> size lower the input array size, which is the behaviour i see.
> > 
> > It's not an error to not write everything.
> 
> It most certainly should be. Either everything got written or there was
> a failure, device buffer full, whatever.
> The only reason to not write everything is some error happened.

But how would you report that some of it got written successfully? It may be 
sufficient for the upper layer.

Imagine the case of disk full. The application may be able to free up space or 
it could decide to wait until some other process did. But it needs to know how 
much of its data it did write.

No, partial writes are success, so long as they report how much was 
successful. This is the case as well for write(2) and WriteFile.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center






More information about the Interest mailing list