[Qt-interest] anyone know why QDir::mkpath() isn't static?
Paul Miller
paul at fxtech.com
Tue Apr 12 18:30:40 CEST 2011
> 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");
>
> ------------------
> I have found there are a number of little idiosyncrasies in the QFile, QFileInfo, and QDir code that can be confusing and worst case create a bug.. You just get used to them :)
>
> With mkpath... I would prefer if there was a static as well as a non-static member... I wouldn't even mind if the QDir threw an assert on the static member if the path sent in was relative.
Yeah I think this is a good case for a separate static method (similar
to remove, rename, and exists found in QFile) that takes an absolute
path (which is the only way I've ever used it).
Allowing this:
QDir dir("/some/path");
dir.mkpath("/some/entirely/different/path");
just feels like a design flaw.
More information about the Qt-interest-old
mailing list