[Development] QTemporaryDir API

David Faure david.faure at kdab.com
Fri Nov 18 11:59:39 CET 2011


On Friday 18 November 2011 11:32:09 Olivier Goffart wrote:
> On Friday 18 November 2011 05:01:44 Jason A. Donenfeld wrote:
> > A general [static] recursive remove directory function belongs in QDir.
> > 
> > A member recursive remove *this* particular *temporary* directory
> > function belongs in QTemporaryDir.
> > 
> > Putting a generalized recursive remove directory function into
> > QTemporaryDir makes no organizational sense.

Did you read the argumentation at 
http://developer.qt.nokia.com/forums/viewthread/9860/
?

One good reason for having it there, is that there are tons of different ways 
to handle errors. And the way that it picked by QTemporaryDir::removeDir is to 
keep going as much as possible.

When removing a user's directory, maybe you want to stop at the first error, 
instead. Or to pop up a dialog about the error and offer 
continue/abort/skip/etc.

So for the one particular implementation of "remove as much as possible in 
order to free space in /tmp", having it in QTemporaryDir makes sense.

> I agree with that,  IMHO it belongs to QDir.
> 
> About the fact that the function is dangerous, yes it is,  but it is
> something developers want to do anyway, and not only with temporary
> directories.

I agree that "dangerous" is not a valid argument, QFile::remove is dangerous 
too. But error handling is a valid argument.

The alternative is to have QDir::removeRecursive(StopOnError | 
ContinueOnError) of course. I'd be fine with that. But apparently we still 
need to convince Lars that it's ok :)

-- 
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