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

Thiago Macieira thiago.macieira at intel.com
Mon May 14 08:50:20 CEST 2018


On Sunday, 13 May 2018 23:28:47 PDT alexander golks wrote:
> > In fact, QDataStream can't recover from any errors.
> 
> as you've said, my origin problem is no error.
> wouldn't it be possible for QDataStream to handle this no-errors, too?

It already does.

int QDataStream::writeRawData(const char *s, int len)
{
    CHECK_STREAM_WRITE_PRECOND(-1)
    int ret = dev->write(s, len);
    if (ret != len)
        q_status = WriteFailed;
    return ret;
}

> otherwise, as i still don't know the "no-error" conditions, i would always
> need to use something like QDataStream::writeRawData, which is barely more
> then a QFile::write, and no other operator<< methods.

it will tell you if there was a write failure. See above.

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






More information about the Interest mailing list