[Interest] QFile::write(const QByteArray&) does not write all data?
Elvis Stansvik
elvstone at gmail.com
Fri May 11 12:05:11 CEST 2018
2018-05-11 10:03 GMT+02:00 alexander golks <alex at golks.de>:
> Am Thu, 10 May 2018 23:32:14 -0700
> schrieb Thiago Macieira <thiago.macieira at intel.com>:
>
>> 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.
>>
>
> well, msdn[1] tells me:
> "If the function fails, or is completing asynchronously, the return value is zero (FALSE). To get extended error information, call the GetLastError function."
> and more about async, etc.
Not sure why you bring up this piece of MS docs, when this is about QFile.
>
> but, whatever error there may be, i must resolve this, when i have it. but with current implementation it is silently captured.
It is not silent, you have the return value so you can detect when the
number of written bytes is not equal to the size of the data.
>
> and still, may question remaines valid:
>> but wouldn't this lead missing writes in QDataStream + QFile, as QDataStream needs complete writes, too?
QDataStream will check if the number of bytes written is equal to the
expected. If it is not, it will put itself into
QDataStream::WriteFailed state, which can be checked for by the user.
I'm really not sure what you're suprised by here :P
Elvis
>
> [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365747(v=vs.85).aspx
>
> --
> /*
> * if(ct<0)
> * ct=2; /* Shit happens.. *\/
> * linux-2.6.6/drivers/net/wan/z85230.c
> */
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list