[Interest] Interest Digest, Vol 80, Issue 9

Roland Hughes roland at logikalsolutions.com
Mon May 14 18:21:40 CEST 2018



On 05/14/2018 10:54 AM, Thiago Macieira wrote:
> 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.
A partial read/write is a failure. You need to stop consuming the error, 
making it available via some method in the class.

=====
FREAD(3) Linux Programmer's Manual FREAD(3)

NAME
        fread, fwrite - binary stream input/output

SYNOPSIS
        #include <stdio.h>

        size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);

        size_t fwrite(const void *ptr, size_t size, size_t nmemb,
                      FILE *stream);

DESCRIPTION
        The function fread() reads nmemb items of data, each size bytes 
long, from the stream pointed to by stream, storing them at the location 
given by ptr.

        The function fwrite() writes nmemb items of data, each size 
bytes long, to the stream pointed to by stream, obtaining them from the 
location given by ptr.

        For nonlocking counterparts, see unlocked_stdio(3).

RETURN VALUE
        On  success,  fread()  and fwrite() return the number of items 
read or written.  This number equals the number of bytes transferred 
only when size is 1.  If an error occurs, or the end of the file is
        reached, the return value is a short item count (or zero).

        fread() does not distinguish between end-of-file and error, and 
callers must use feof(3) and ferror(3) to determine which occurred.

=====

Look at that last line. Both fread() and fwrite() set an error value. 
The application can retrieve this value when a partial read/write happens.

The original poster's issue is that Qt is consuming the error. They have 
no method of determining what the error was so the application can make 
an informed decision about how to proceed.

-- 
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/20180514/6bb3c67e/attachment.html>


More information about the Interest mailing list