[Interest] QTemporaryFile::open(OpenMode flags) is protected, but not in documentation
Thiago Macieira
thiago.macieira at intel.com
Thu Sep 26 03:39:08 CEST 2013
On quarta-feira, 25 de setembro de 2013 23:04:42, Etienne Sandré-Chardonnal
wrote:
> I do not want to read first, I want to write data, close, then reopen for
> reading (Used as a buffer for uploading large data over the network and
> avoid keeping it in memory).
Once you close the file, your data is gone. Your data only exists as long as
you keep the file open.
Assuming well-behaved applications running on the system, you can open the file
again in read-only mode, by using the same name. If you cannot assume well-
behaved applications (and defensive coding says you shouldn't), reopening the
file by name is not guaranteed to get the same data. You must pass the already-
open file descriptor.
Now, you can tell QTemporaryFile to abandon the file: that is, set auto
deletion to false and then destroy the object. But like I said above, the file
might be deleted and recreated by another application before you can reopen it
again.
In any case, every time you open a QTemporaryFile, you get a blank file. There
is no data on the file, so it makes no sense to open it in read-only mode.
If you want to open a file with existing data, created by something else, use
QFile, not QTemporaryFile.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130925/35961c1c/attachment.sig>
More information about the Interest
mailing list