Re: [Development] QTemporaryDir API

2011-11-27 Thread Thiago Macieira
On Sunday, 27 de November de 2011 15.45.47, David Faure wrote:
> On Friday 18 November 2011 11:12:16 lars.kn...@nokia.com wrote:
> > Agree, it can be solved by documentation and giving it a name that makes
> > it obvious. QDir::removeAllDirsandFilesRecursive() for example.
>
> OK. I named it removeAllContentsRecursively (slightly shorter).

Aww I was so hoping for
removeAllFilesAndDirsAndOtherInodeEntriesRecursively...

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
 Intel Sweden AB - Registration Number: 556189-6027
 Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden


signature.asc
Description: This is a digitally signed message part.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-27 Thread David Faure
On Friday 18 November 2011 11:12:16 lars.kn...@nokia.com wrote:
> Agree, it can be solved by documentation and giving it a name that makes
> it obvious. QDir::removeAllDirsandFilesRecursive() for example.

OK. I named it removeAllContentsRecursively (slightly shorter).

> So my proposal would be to remove it from QTemporaryDir, and then have
> another merge request adding this as API to QDir.

Done:
http://codereview.qt-project.org/#change,9870
http://codereview.qt-project.org/#change,8297

-- 
David Faure | david.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-18 Thread lars.knoll
On 11/18/11 11:59 AM, "ext David Faure"  wrote:

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

Something like that sounds ok. Certainly better then having the thing in
QTempDir.

Cheers,
Lars

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-18 Thread lars.knoll
On 11/18/11 11:32 AM, "ext 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.
>
>
>I agree with that,  IMHO it belongs to QDir.

Yes, one of my problems with it was that it does clearly not belong into
QTemporaryDir, but 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.

Agree, it can be solved by documentation and giving it a name that makes
it obvious. QDir::removeAllDirsandFilesRecursive() for example.

So my proposal would be to remove it from QTemporaryDir, and then have
another merge request adding this as API to QDir.

Cheers,
Lars


>
>
>> $0.02
>
>0.02€
>
>-- 
>Olivier
>___
>Development mailing list
>Development@qt-project.org
>http://lists.qt-project.org/mailman/listinfo/development

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-18 Thread David Faure
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.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-18 Thread Olivier Goffart
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.


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.


> $0.02

0.02€

-- 
Olivier
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-18 Thread Jason A. Donenfeld
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.

$0.02

- Jason
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread Roopesh Chander
On Thu, Nov 17, 2011 at 9:54 PM, David Faure  wrote:

> – 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).


I wouldn't really think of dirs with saved sessions as "temporary". When
reading code like the following, I'm afraid it would appear like it's
abusing a feature of QTemporaryDir:

// remove session
QTemporaryDir::removeDir(userHomeDir + "/.kde/session/" + sessionId);

That said, I definitely agree that QDir::removeRecursive() might not be
appropriate, because we intend it to be not used on user-visible
directories.

A compromise could be to call the static method 'removeInternalDir'. Like
so:

// remove session
QDir::removeInternalDir(userHomeDir + "/.kde/session/" + sessionId);

To make it a little more harder for users to shoot themselves in the foot,
I suggest there be another option to specify what contents of the internal
dir is allowed to be deleted. So:

// if dirPath contains anything at all, returns false
bool ok = QDir::removeInternalDir(dirPath, QDir::RemoveEmptyDir
/*default*/);

// if there are any dirs in dirPath, returns false
bool ok = QDir::removeInternalDir(dirPath, QDir::RemoveContainedFiles);

// if there are any files in dirPath, returns false
bool ok = QDir::removeInternalDir(dirPath, QDir::RemoveContainedDirs);

// rm -rf
bool ok = QDir::removeInternalDir(dirPath, QDir::RemoveContainedFiles |

QDir::RemoveContainedDirs |
QDir::RemoveRecursively
);

Unfortunately, I can't think of valid use-cases for delete-files-only and
delete-dirs-only calls.

roop.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread Charley Bay
On Thu, Nov 17, 2011 at 9:24 AM, David Faure  wrote:

> On Thursday 17 November 2011 17:14:06 Robin Burchell wrote:
> > On Thu, Nov 17, 2011 at 5:11 PM, David Faure 
> 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 :
>

IMHO, anything that hits the file system should be centralized.  It's
"outside the process", and  potentially "dangerous" (especially any
non-read action).

I like the QTemporaryDir idea.  I would like to keep it, but merely "move"
the actual file-system-hitting-stuff to some central QFileSystemHitter
class (which would be used in the implementation of QTemporaryDir), so an
application can breakpoint, centralize, check-point, or otherwise "control"
what file system hits occur.

For example, the QFileSystemHitter::RemoveDir() could receive *every*
"remove-dir" operation, and "filter" to only *actually* remove those dirs
which the application gave "permission" to remove.  In this case, the
application may set "these-dirs-you-control", and the QFileSystemHitter
would *fail* on any operation that is not in those subdirs.

We hit the file system a lot, and that's the design we have.

--charley
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread David Faure
On Thursday 17 November 2011 17:14:06 Robin Burchell wrote:
> On Thu, Nov 17, 2011 at 5:11 PM, David Faure  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.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread Robin Burchell
On Thu, Nov 17, 2011 at 5:11 PM, David Faure  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.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread David Faure
On Thursday 17 November 2011 13:52:55 lars.kn...@nokia.com wrote:
> Hi David,
> 
> looks good in general.
> 
> I am however concerned about the static removeDir() method. This one is
> pretty much the equivalent of a 'rm -rf'. Since it's not limited to
> temporary directories, so it doesn't match the class.
> 
> It's also a rather dangerous operation, and I'm worried we'll see bugs in
> it's usage leading to users home directories being blown away.

Well this is actually one of the reasons for having it in QTemporaryDir rather 
than in QDir : to make it clear that this should only be used for 
programmatically created dirs (mostly temp dirs, but there are a few other use 
cases like apps saving stuff into dirs). Not as a general QDir method to be 
used .

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

But I fail to see why "this API could be misused" is a reason for not having 
it. I mean, one could make the same argument against having QFile::remove in 
the API -- it could be used to delete the document that a user spent days to 
write!

In any case: see http://developer.qt.nokia.com/forums/viewthread/9860/ for the 
"popular demand" for such a method. I could be convinced to put it into QDir, 
I would also be very happy to leave it in QTemporaryDir, for "almost-like a 
temp dir but not created by QTemporaryDir because a random naming isn't 
wanted". But I think it would be a mistake to not have any recursive deletion 
method, available, still, in Qt5.

Note that KTemporaryDir had a removeDir method for many many years and nobody 
ever blamed the kdelibs developers for "bugs in its usage leading to users 
home dirs being blown away"...
If the app developers implement their own version and call it wrongly, then 
the users still lose data, and worse, we make this more likely by not 
providing a well-tested method to app developers.
E.g. it's not only about the starting directory. There's the issue of not 
following symlinks to directories. Any naive implementation based on QFileInfo 
will get this wrong, and will follow symlinks. Ouch!

-- 
David Faure | david.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread André Pönitz
On Thursday 17 November 2011 14:52:55 ext lars.kn...@nokia.com wrote:
> Hi David,
> 
> looks good in general.
> 
> I am however concerned about the static removeDir() method. This one is
> pretty much the equivalent of a 'rm -rf'. Since it's not limited to
> temporary directories, so it doesn't match the class.
> 
> It's also a rather dangerous operation, and I'm worried we'll see bugs in
> it's usage leading to users home directories being blown away.

The alternative is that each user rolls his own. Of course, he can't
blame Qt then if that fails...

I'd actually like to have that functionality in Qt, but with a name that
stands out and makes it very clear that it is "dangerous".

removeAllFilesAndDirectoriesRecursively(..., Qt::IReallyMeanIt)  ;-)

Andre'
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-17 Thread lars.knoll
Hi David,

looks good in general.

I am however concerned about the static removeDir() method. This one is
pretty much the equivalent of a 'rm -rf'. Since it's not limited to
temporary directories, so it doesn't match the class.

It's also a rather dangerous operation, and I'm worried we'll see bugs in
it's usage leading to users home directories being blown away.

Cheers,
Lars


On 11/16/11 6:13 PM, "ext David Faure"  wrote:

>Hello,
>
>As previously discussed on qt5-feedback, I wrote QTemporaryDir and
>submitted 
>it to gerrit at http://codereview.qt-project.org/#change,8297
>After a few reviews from Thiago (and redoing the implementation on
>Windows)
>it's now ready for submission. Thiago suggested that I post the header
>file 
>here, to see if anyone had feedback on the (rather short) API.
>
>Actually I'll post the .cpp file too, since the documentation of the API
>is 
>there :)
>
>-- 
>David Faure, fa...@kde.org, http://www.davidfaure.fr
>Sponsored by Nokia to work on KDE, incl. KDE Frameworks
>5___
>Development mailing list
>Development@qt-project.org
>http://lists.qt-project.org/mailman/listinfo/development

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-16 Thread Andre Somers
Op 16-11-2011 18:56, David Faure schreef:
> On Wednesday 16 November 2011 18:26:25 Andre Somers wrote:
>> Op 16-11-2011 18:13, David Faure schreef:
>>> Hello,
>>>
>>> As previously discussed on qt5-feedback, I wrote QTemporaryDir and
>>> submitted it to gerrit at http://codereview.qt-project.org/#change,8297
>>> After a few reviews from Thiago (and redoing the implementation on
>>> Windows) it's now ready for submission. Thiago suggested that I post
>>> the header file here, to see if anyone had feedback on the (rather
>>> short) API.
>>>
>>> Actually I'll post the .cpp file too, since the documentation of the API
>>> is there :)
>> There is no need to assing copyright to nokia :-)
> I am being sponsored by Nokia for my work on KDE, and right now this involves
> putting into Qt 5 what KDE needs. So it kind of makes sense that Nokia owns
> the copyright for it.
>
>
Ah, good point :-) Nokia (c) it is, then.

André

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-16 Thread David Faure
On Wednesday 16 November 2011 18:26:25 Andre Somers wrote:
> Op 16-11-2011 18:13, David Faure schreef:
> > Hello,
> > 
> > As previously discussed on qt5-feedback, I wrote QTemporaryDir and
> > submitted it to gerrit at http://codereview.qt-project.org/#change,8297
> > After a few reviews from Thiago (and redoing the implementation on
> > Windows) it's now ready for submission. Thiago suggested that I post
> > the header file here, to see if anyone had feedback on the (rather
> > short) API.
> > 
> > Actually I'll post the .cpp file too, since the documentation of the API
> > is there :)
> 
> There is no need to assing copyright to nokia :-)

I am being sponsored by Nokia for my work on KDE, and right now this involves 
putting into Qt 5 what KDE needs. So it kind of makes sense that Nokia owns 
the copyright for it.


(Yeah it's confusing, I'm posting this email as kdab.com instead of nokia-
sponsored kde.org, but that's because subscribing with my kde.org address did 
not work, despite several attempts... never got any subscription emails).

-- 
David Faure | david.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-16 Thread David Faure
On Wednesday 16 November 2011 18:22:23 Harri Porten wrote:
> On Wed, 16 Nov 2011, David Faure wrote:
> > Thiago suggested that I post the header file here, to see if anyone had
> > feedback on the (rather short) API.
> > 
> > Actually I'll post the .cpp file too, since the documentation of the API
> > is there :)
> 
> I tried without the documentation. Feedback based on that:

Hi Harri!
Thanks for the feedback.

> 1.) I found the argument name "templateName" a bit confusing as it could
> also refer to the name of a template. How about "nameTemplate"? :)
> 
>QTemporaryDir(const QString &templateName);

Good idea. This is based on QTemporaryFile's similar naming, though.

> 2.) I cannot remember details of Qt's naming policies anymore but
> autoRemove() very much sounds like an action. isAutoRemoved() would be
> clearer? The "auto" abbreviation is still questionable.

Same here, this is for consistency with QTemporaryFile, and that's part of the 
existing API so I wouldn't change that.

> 3.) Shouldn't QTemporaryDir::removeDir(const QString& path) rather be a
> removeRecursive() function in QDir?

Arguable. See what the documentation for it says :-) And the discussion at 
http://developer.qt.nokia.com/forums/viewthread/9860/
ending with http://developer.qt.nokia.com/forums/viewthread/9860/P15

-- 
David Faure | david.fa...@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

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-16 Thread Andre Somers
Op 16-11-2011 18:13, David Faure schreef:
> Hello,
>
> As previously discussed on qt5-feedback, I wrote QTemporaryDir and submitted
> it to gerrit at http://codereview.qt-project.org/#change,8297
> After a few reviews from Thiago (and redoing the implementation on Windows)
> it's now ready for submission. Thiago suggested that I post the header file
> here, to see if anyone had feedback on the (rather short) API.
>
> Actually I'll post the .cpp file too, since the documentation of the API is
> there :)
>
There is no need to assing copyright to nokia :-)

André

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] QTemporaryDir API

2011-11-16 Thread Harri Porten
On Wed, 16 Nov 2011, David Faure wrote:

> Thiago suggested that I post the header file here, to see if anyone had 
> feedback on the (rather short) API.
>
> Actually I'll post the .cpp file too, since the documentation of the API is
> there :)

I tried without the documentation. Feedback based on that:

1.) I found the argument name "templateName" a bit confusing as it could 
also refer to the name of a template. How about "nameTemplate"? :)

   QTemporaryDir(const QString &templateName);

2.) I cannot remember details of Qt's naming policies anymore but 
autoRemove() very much sounds like an action. isAutoRemoved() would be 
clearer? The "auto" abbreviation is still questionable.

3.) Shouldn't QTemporaryDir::removeDir(const QString& path) rather be a 
removeRecursive() function in QDir?

Harri.
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] QTemporaryDir API

2011-11-16 Thread David Faure
Hello,

As previously discussed on qt5-feedback, I wrote QTemporaryDir and submitted 
it to gerrit at http://codereview.qt-project.org/#change,8297
After a few reviews from Thiago (and redoing the implementation on Windows)
it's now ready for submission. Thiago suggested that I post the header file 
here, to see if anyone had feedback on the (rather short) API.

Actually I'll post the .cpp file too, since the documentation of the API is 
there :)

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5/
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-i...@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
/

#ifndef QTEMPORARYDIR_H
#define QTEMPORARYDIR_H

#include 

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Core)

#ifndef QT_NO_TEMPORARYFILE

class QTemporaryDirPrivate;

class Q_CORE_EXPORT QTemporaryDir
{
public:
QTemporaryDir();
explicit QTemporaryDir(const QString &templateName);
~QTemporaryDir();

bool isValid() const;

bool autoRemove() const;
void setAutoRemove(bool b);
bool remove();

QString path() const;

static bool removeDir(const QString& path);

private:
QTemporaryDirPrivate* const d_ptr;

Q_DISABLE_COPY(QTemporaryDir)
};

#endif // QT_NO_TEMPORARYFILE

QT_END_NAMESPACE

QT_END_HEADER

#endif // QTEMPORARYDIR_H/
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-i...@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
/

#include "qtemporarydir.h"

#ifndef QT_NO_TEMPORARYFILE

#include "qdiriterator.h"
#include "qplatformdefs.h"
#include "private/qdir_p.h"

#if defined(QT_BUILD_CORE_LIB)
#include "qcoreapplication.h"
#endif

#include  // mkdtemp
#ifdef Q_OS_WIN
#include 
#endif

QT_BEGIN_NAMESPACE

//* QTemporaryDirPrivate
cl