[Interest] QFile::write(const QByteArray&) does not write, all data?
alexander golks
alex at golks.de
Fri May 18 07:23:29 CEST 2018
Am Thu, 17 May 2018 10:31:55 -0500
schrieb Roland Hughes <roland at logikalsolutions.com>:
> On 05/17/2018 09:11 AM, alexander golks wrote:
> >> my code was:
> >> qint64 res = f.write(data);
> > just for the curious ones:
> >
> > i have at least compiled 5.6.4 now, but i can not produce the error with my qt5core.
> > using 5.6.3 from qt, error exists. using mine, does not exist...
> >
> > getting the error code directly after the f.write(data) gives me error code 183:
> > ERROR_ALREADY_EXISTS
> > 183 (0xB7)
> > Cannot create a file when that file already exists.
> >
> > but i assume, that the error is not from the failing WriteFile call. or does it?
> > anyone with some more ideas?
> > e.g. on how to reproduce or test?
>
> One of the annoying safety features of Qt is that it won't overwrite a
> file. You got that error when you tried to open the file for output and
> you didn't check for the error. There was some test case long ago where
> it was deemed a security risk for Qt to overwrite existing files. This
> deviates from standard C/C++ where you can. Before opening an output
> file you need to test for its existence then delete it. You can also
> play games with opening the file for I/O and truncating, but, success is
> file system dependent on that one.
>
the QFile::write call returns with no error, i called GetLastError() after the QFile::write() and got 183.
the file is written up to ~30MB, and suddenly already exists?
i am pretty sure, the file doesn't exist prior the call.
--
/*
*You will meet an important person who will help you advance professionally.
*/
More information about the Interest
mailing list