API robustness - (was: Different ways to create a directory)

David Faure faure at kde.org
Fri Aug 14 10:38:31 BST 2009

On Friday 14 August 2009, Andreas Pakulat wrote:
> I agree here, I don't see a reason why an app developer should need to care
> wether the KUrl which he wants to use to create a directory is a remote or
> local one. 

I agree, *if* you indeed have a KUrl to start with. In that case, yes, just use KIO.

But please, look at the existing code in many apps, there are many use cases
for always-local-files (as I said, everything in $KDEHOME, plus others), 
there's no reason to use kio for this, you get more performance and features
from qdir/qfile in such a case.

> The KFoo::mkdir function should "just work" in either case,
> hence using kio if its a remote url or QFile::mkdir for a local one. 

But that means asynchronous API.

> It may be justified to have a KStandardDirs::mkdir( <type>, "dirname" ) to
> easily create a directory within one of the various standard dirs as
> convenience function.

locateLocal takes care of this, but that's not the KStandardDirs method we were talking about.
KStandardDirs::makeDir() is quite kstandarddirs-unrelated, it's a QDir::mkpath() with mode_t support. I start to repeat myself, but it seems my points are being ignored :)

David Faure, faure at kde.org, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

More information about the kde-core-devel mailing list