Problem while retriving content from a directory...?

Login to reply to this topic.
Fri, 2008-03-14 16:16
Joined: 2008-01-29
Forum posts: 18

Hi rbrunner this is amit once again. I am havins some problems regarding GetDir() function.
i am using the following code to retrieve the contents inside the directory by passing _L("c:\\") in aRootFolderPath.

RFs aFs;
aFs.Connect();
CDir *aDirList ;
CDir *anEntryList;

if(aFs.GetDir(aRootFolderPath,KEntryAttNormal,ESortByName, anEntryList, aDirList)==KErrNone)
{
if(aDirList->Count() > 0)
{
for(TInt i= 0;iCount();i++)
{

TInt length=(*aDirList).iName.Length();
TBuf<512> name =(*aDirList)[i].iName;
.....................................................
}
}
}

But the issue is that in variable [i]length [b] i am getting some garbage value and the iName is not returning anything.


Sat, 2008-03-15 07:12
Joined: 2005-11-20
Forum posts: 1248
Re: Problem while retriving content from a directory...?

I am not sure what is the problem, but I am pretty sure that the code you list here is not the code that you really execute, because what you list here does not compile in at least two places:
for(TInt i= 0;iCount();i++)
TInt length=(*aDirList).iName.Length();

You might check again and post the real code here.


René Brunner

Sat, 2008-03-15 07:48
Joined: 2008-01-29
Forum posts: 18
Re: Problem while retriving content from a directory...?

RFs aFs;
aFs.Connect();
CDir *aDirList ;
CDir *anEntryList;

if(aFs.GetDir(aRootFolderPath,KEntryAttNormal,ESortByName, anEntryList, aDirList)==KErrNone)
{

TInt length=(*aDirList).iName.Length();
TBuf<512> name =(*aDirList)[i].iName;
.....................................................


}

Sat, 2008-03-15 08:41
Joined: 2005-11-20
Forum posts: 1248
Re: Problem while retriving content from a directory...?

TInt length=(*aDirList).iName.Length();

This line does not make sense to me, and if it compiles, I don't know why. aDirList is a pointer to something like an array, so (*aDirList) cannot directly have a component .iName, like you write. Maybe what you want is this:

TInt length=(*aDirList)[i].iName.Length();

for checking the length of the name of the first entry (with i=0) in the array?


René Brunner

  • Login to reply to this topic.