How to distinguish a file from a folder.
| Wed, 2007-02-14 10:40 | |
|
Hi,
I have a function which needs to examine all files within a folder. I'm currently doing this as follows: void CProcessFile::ScanDirL(RFs& aFs, const TDesC& aDir, const TDesC& aWild) TFindFile find(aFs); CDir* dir; TParse parse; parse.Set(aWild, &aDir, NULL); TPtrC spec(parse.FullName()); HBufC16 *tmpBuf = HBufC16::NewLC(KMaxPath); TPtr16 tmpPtr = tmpBuf->Des(); if (!find.FindWildByPath(parse.FullName(), NULL, dir)) { CleanupStack::PushL(dir); for(TInt i = 0; i < dir->Count(); i++) { parse.Set((*dir)[i].iName, &spec, NULL); tmpPtr = parse.FullName(); ProcessFile((const TDesC16&)*tmpBuf); } CleanupStack::PopAndDestroy(dir); } CleanupStack::PopAndDestroy(tmpBuf); return; The problem with this code is that "parse.Set((*dir)[i].iName, &spec, NULL)" returns both files and folders - I only want to know about files. Please can someone tell me how to either distinguish between a file and a directory, or provide an alternative filtering out directories. (For example, I note that CDirScan::SetScanDataL provides a filter, but this returns a list of all files in the hierarchy, not just the current folder.) If it helps, this is being developed on Symbian 8, although it will be useful if the algorithm is also supported on earlier releases. Many thanks, Dave-V |
|






Forum posts: 683
Forum posts: 214
scan->SetScanDataL(KFileFolder,KEntryAttMatchMask,ESortByName|EAscending,CDirScan::EScanDownTree);
CDir* folders = NULL;
TRAPD(error, scan->NextL(folders));
for(...)
{TEntry entry=(*folders)[i];
if(entry.IsDir())
continue;
}
"I only know that I know nothing." (Socrates)
Forum posts: 28
Dave