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

Roland Hughes roland at logikalsolutions.com
Sat May 12 16:45:21 CEST 2018



On 05/12/2018 08:57 AM, Thiago Macieira wrote:
> On Friday, 11 May 2018 04:08:48 PDT alexander golks wrote:
>>> 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.
>> the error is 0. and errorString() is "no error", too.
>> so how to evaluate for error or no error?
> No error. It just wrote less than what you supplied.
Which would be caused by an error, but he cannot find out what the error 
was. Any time a write comes up short, it is an error. Something ranging 
from annoying to bad happened. Annoying would be the device write cache 
got full. If he knows that is what happened he can compensate for this. 
Worst case, sleep for a second and write the rest. If the destination 
device is full or has went into read-only mode (annoying little problem 
with Linux and MicroSD caused by trying to write too much at once and 
then trying to read it back in before the write completes) he needs the 
application to inform someone a physical error requiring human 
interaction has occurred.

His point is that he has no reliable programmatic method of determining 
an appropriate course of action. With the current code base his only 
method of determining a human intervention needed error happened is to 
continually retry writing until the error occurs in the first chunk.

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog
http://lesedi.us/
http://onedollarcontentstore.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180512/cc12b2a6/attachment.html>


More information about the Interest mailing list