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");
Qdir dir("John");
dir.mkpath("Kathy");
To copy to clipboard, switch view to plain text mode
The result is John/Kathy which is not what I expected especially because my intended usage was as follows.
if (!dir.exists()) {
dir.mkpath("John");
}
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("John");
}
To copy to clipboard, switch view to plain text mode
However the result is
John/John
is created.
I tried
if (!dir.exists()) {
dir.mkpath(".");
}
QDir dir("John");
if (!dir.exists()) {
dir.mkpath(".");
}
To copy to clipboard, switch view to plain text mode
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
if (!dir.exists()) {
dir.mkpath("");
}
QDir dir("John");
if (!dir.exists()) {
dir.mkpath("");
}
To copy to clipboard, switch view to plain text mode
it exits with false because the path can not be empty.
Bookmarks