[Development] QTemporaryDir API

David Faure david.faure at kdab.com
Thu Nov 17 17:24:20 CET 2011


On Thursday 17 November 2011 17:14:06 Robin Burchell wrote:
> On Thu, Nov 17, 2011 at 5:11 PM, David Faure <david.faure at kdab.com> wrote:
> > The method already asserts if the path is empty or is ".", we could make
> > that stricter to catch more bugs (error instead of debug-mode-only
> > assert, and refuse more paths, including the home dir).
> 
> Why does it need to be static at all, as opposed to the API user being
> able to explicitly remove the QTemporaryDir they've created
> themselves? No room for bugs, or removing the wrong directory.

That's what the non-static remove() is about.

But the static removeDir covers other cases, like the ones I mentionned at 
http://developer.qt.nokia.com/forums/viewthread/9860/P15 :

– fixed-named temp dirs as used by unittests for easier debugging. 

This is very very common in unittests (in both Qt and KDE), and is a good 
argument for having the method in QTemporaryDir: it is about temp dirs, just 
not randomly-named ones.

– konqueror sessions which are saved on disk as directories.
I'm sure there are other similar cases of apps saving internal stuff as 
directories. Calling these "temporary" might be a bit arguable, but if the 
general agreement here is that a QDir::removeRecursive would be even worse, 
then I think this is a good compromise. It makes it clear that it's for app-
created dirs (which get deleted at some point, so they are "temporary" in a 
way), not for user directories (which might be huge and contain lots of 
important data).

-- 
David Faure | david.faure at kdab.com | KDE/Qt Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions




More information about the Development mailing list