PDA

View Full Version : how to use same directory name with different path



iswaryasenthilkumar
27th April 2015, 14:36
i have doubt in QDir,
i declared directory with one path (exampl path1)and am checking if the directory exist,,after thsi execution am using same directory name with changing path to another and also checking exist,like wise am checking multiple path,, am not getting good result while checking this
Example


QDir dir(path1);
if(!path1.exist) // this alone executing correctly
{
dir.cd("somefolde");
//doing some action
qdebug("path not exist");
}

dir.cd(path2)
{
if(!path2.exist) //this not executing it showimg wrong output
{
dir.cd("somefolde");
//doing some action
qdebug("path not exist");
}
dir.cd(path3)
{
if(path2.exist) //this not executing it showimg wrong output
{
doing some action//
}

i know am doing mistake,,can any one clear my doubt please:confused:
Thanks in advance:o

anda_skoa
27th April 2015, 16:07
Your code has way to many application specific things.
For example, if we assume this compiles, you have an application specific data structure that has an "exist" field (e.g. "path1.exist") and can be implicitly converted to either QString or QDir (the two constructor variants that can create a QDir with one argument).

So how does the type of path1, path2 and path3 look like. how does it determine the value of exist?
Why do you try to change into a subdirectory of a path that doesn't exist?

Cheers,
_

iswaryasenthilkumar
28th April 2015, 05:49
Why do you try to change into a subdirectory of a path that doesn't exist?

Cheers,
_
am checking for if that particular directory not exist do some action thats why i used doesn't exist for subdirectory
if subdirectory path will not used to check doesn,t exist ah??

anda_skoa
28th April 2015, 06:51
You don't make any sense.

If a path doesn't exist, how do you expect to be able to switch into a subdirectory below it?
Obviously that won't exist either.

Cheers,
_