[Qt-interest] anyone know why QDir::mkpath() isn't static?

Atlant Schmidt aschmidt at dekaresearch.com
Tue Apr 12 18:21:24 CEST 2011


Paul:

To expand on Thiago's rather cryptic response, in
your case, the constructor and the method really
*ARE* somewhat redundant but that's because you're
not using the full beauty and grandeur [;-)] of
the class.

What you've really got when you construct a QDir
is a sort of "cd" ("current working directory");
you've got an object that now points to some
directory that exists (or at least could exist)
somewhere within your file system. You can then
do all sorts of common manipulations to this
working directory such as cd'ing downwards or
upwards, extracting bits and pieces of the path,
and so on.

You can also create new paths (or individual
directories) relative to this current working
directory (and these can be absolute paths if
the current working directory is an absolute
path).

It only feels redundant because you're doing
essentially the simplest possible pair of
operations where, yes, it may be "overkill"
compared to mkdir(2).

                   Atlant


-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Thiago Macieira
Sent: Tuesday, April 12, 2011 12:11
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] anyone know why QDir::mkpath() isn't static?

Em terça-feira, 12 de abril de 2011, às 10:55:46, Paul Miller escreveu:
> To use QDir::mkpath() you have to do this:
>
> QDir dir("/the/path/you/want/to/create");
> dir.mkpath(dir.absolutePath());
>
> Seems the argument to mkpath() is redundant, or, since the argument
> overrides the QDir's actual path, the whole constructor is irrelevant.
> Shouldn't it mkpath() be static?

QDir dir("/the/path/you/want/");
dir.mkpath("to/create");

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.



More information about the Qt-interest-old mailing list