PDA

View Full Version : QDir spawning dir when not existing.



soxs060389
26th January 2010, 10:36
It sounds real easy, and as the Doc states it should work like this, but all I get is "unable to spawn"


void blah(const QString &basedir){
QDir dir(_basedir);
if (!dir.exists()){
qDebug() << "Dir " << _basedir << " does NOT exists";
if (dir.mkpath(_basedir)){
qDebug() << "Spawned base dir " << _basedir;
}
else{
qDebug() << "Unable to spawn base dir " << _basedir;

return;
}
}
}
Note: _basedir may be absolute or relative

may somone please point me to my mistake, I don't really see any.

I allready read the doc twice, but I don't see any hint about this..

thanks for any reply

vishwajeet.dusane
26th January 2010, 13:08
Hi


I tried your code on my win Xp machine with 4.6.0 and it works fine for absolute as well as relative path however i had to change
#
void blah(const QString &basedir){ to _basedir.
That may not be the problem or may be it is ? can you check if you already have this _basedir variable globally declare with some different values ?
i am assuming that your function parameter should be _basedir. correct me if i m wrong.

soxs060389
26th January 2010, 20:27
You are right, but that's not the point, I just picked it from a class method to a function vereyone could easily test. Fixed typo.

I am on Linux and I'd like to hear some voice testing that on linux/*nix systems.