[Development] QFile: writing via a temporary file

David Faure faure at kde.org
Fri Jan 6 18:36:10 CET 2012


On Friday 06 January 2012 09:50:14 Artur Souza (MoRpHeUz) wrote:
> On Thu, Jan 5, 2012 at 8:32 PM, David Faure <faure at kde.org> wrote:
> > Now there's just one question remaining: even if the rule is that all
> > operations apply to the temp file, between open and close... what should
> > QFile::fileName() return? The temp file name, to obey that rule, or the
> > target file name, for symmetry with setFileName()?
> > 
> > I'm tempted to say: the latter, because the temp file is really internal,
> > and to prevent surprises (breaking symmetry with setFileName). Of course
> > it means file.remove() won't be the same as
> > QFile::remove(file.fileName()) anymore... :)
> But imagine the following scenario:
> 
> file.setUseTemporaryFile(true)
> file.open()
> file.write()
> ----> APP CRASHES
> 
> If file.fileName() would return the original filename, how one can
> restore the temp file? Would the temporary filename be deterministic?

No, no, the whole idea of this feature is not to use the temp file as a backup.
If the app crashes, you lose your partially-writen temporary file.
That's fine, it was partial anyway, why would you want to use it?

I think you're confusing this with a backup feature, which is unrelated.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5




More information about the Development mailing list