drescherjm
4th March 2009, 23:00
I am trying to figure out the intend usage of QDir::mkpath
On Qt 4.3 on windows XP
Qdir dir("John");
dir.mkpath("Kathy");
The result is John/Kathy which is not what I expected especially because my intended usage was as follows.
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("John");
}
However the result is
John/John
is created.
I tried
QDir dir("John");
if (!dir.exists()) {
dir.mkpath(".");
}
and got what I wanted (created just John in the current folder) however I am unsure that this will work on all platforms.
Also if you
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("");
}
it exits with false because the path can not be empty.
On Qt 4.3 on windows XP
Qdir dir("John");
dir.mkpath("Kathy");
The result is John/Kathy which is not what I expected especially because my intended usage was as follows.
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("John");
}
However the result is
John/John
is created.
I tried
QDir dir("John");
if (!dir.exists()) {
dir.mkpath(".");
}
and got what I wanted (created just John in the current folder) however I am unsure that this will work on all platforms.
Also if you
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("");
}
it exits with false because the path can not be empty.