week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-CA35A708-C6D9-51D7-873B-A79606FFAF66"><title>How to search for files with TFindFile</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The following example accumulates a list of all the files on any drive which are in a particular directory and which match a name with wildcards, for example, all files matching <filepath>\resources\fonts\*.gdr</filepath>. </p> <p>To start a search, use <codeph>TFindFile::FindWildByDir()</codeph>. You can then call <codeph>TFindFile::FindWild()</codeph> to perform the same search on another drive. </p> <p>To retrieve the fully qualified path of the matching files, class <codeph>TParse</codeph> is used to combine the filename with the drive letter and directory which contains the file. The example works as follows: </p> <ol id="GUID-E589950F-603A-5BB3-9387-06D1B2CE2E4B"><li id="GUID-A748895E-D312-505C-A2D7-3C35952F7913"><p>Construct a <codeph>TFindFile</codeph> object. </p> </li> <li id="GUID-A6DE36F9-033A-534B-A27D-A3B8FC50A8D5"><p>Use <codeph>FindWildByDir()</codeph> to start the search for matching files. There is considerable flexibility in the handling of <codeph>aWildName</codeph> and <codeph>aScanDir</codeph>, but the simplest and most common case is where <codeph>aWildName</codeph> is the filename and extension (for example, <filepath>*.gdr</filepath>) and <codeph>aScanDir</codeph> is the directory name, without a drive letter, but including a trailing directory separator (for example, <filepath>\resources\fonts\</filepath>). </p> </li> <li id="GUID-44EE24DB-880F-52A4-85E1-02C575CC6B9F"><p>The list of matching files is returned in a <codeph>CDir</codeph> object, which is implemented as an array. <codeph>Count()</codeph> retrieves the number of items in the list. </p> </li> <li id="GUID-FE931EA6-0AB0-5D5C-88ED-7E4F506DDE60"><p>Use <codeph>file_finder.File()</codeph> to retrieve the drive and path of the folder containing the files in the <codeph>CDir</codeph>, (for example <filepath>Z:\resources\fonts\</filepath>). </p> </li> <li id="GUID-67ACA73A-CDDE-5C95-8B31-4D421BE4D95D"><p>Use <codeph>TParse::Set()</codeph> to combine the file name and path into a full filename. </p> </li> <li id="GUID-B9EEB198-264B-5A82-869D-329077498849"><p>Use <codeph>TFindFile::FindWild()</codeph> to continue the search on the next drive in the search sequence. </p> </li> </ol> <codeblock id="GUID-FECFC563-7050-5A63-B29F-BF757B608818" xml:space="preserve">void ForAllMatchingFiles(RFs& aSession, const TDesC& aWildName,
const TDesC& aScanDir)
{
TFindFile file_finder(aSession);
CDir* file_list;
TInt err = file_finder.FindWildByDir(aWildname,aScanDir, file_list);
while (err==KErrNone)
{
TInt i;
for (i=0; i<file_list->Count(); i++)
{
TParse fullentry;
fullentry.Set((*file_list)[i].iName,& file_finder.File(),NULL);
// Do something with the full filename...
// ...
}
delete file_list;
err=file_finder.FindWild(file_list);
}
}</codeblock> <section><title>Notes</title> <ul><li id="GUID-70ACE146-F1EF-50DE-8B9A-C6A7AEAB14A3"><p> <codeph>(*file_list)[i].iName</codeph> is the name of a file matching the pattern specified (e.g. <filepath>Eon.gdr</filepath>). </p> </li> <li id="GUID-F002137B-9501-5552-9B33-09CFF804B922"><p>It is your responsibility to delete the <codeph>CDir</codeph> object when you have finished with it. </p> </li> </ul> </section> </conbody></concept>