Symbian3/SDK/Source/GUID-CA35A708-C6D9-51D7-873B-A79606FFAF66.dita
changeset 7 51a74ef9ed63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-CA35A708-C6D9-51D7-873B-A79606FFAF66.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,71 @@
+<?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 id="GUID-CA35A708-C6D9-51D7-873B-A79606FFAF66" xml:lang="en"><title>How
+to search for files with TFindFile</title><shortdesc>This topic provides an example on how to search for files with
+TFindFile.</shortdesc><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&amp; aSession, const TDesC&amp; aWildName, 
+            const TDesC&amp; 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&lt;file_list-&gt;Count(); i++)
+            {
+            TParse fullentry;
+            fullentry.Set((*file_list)[i].iName,&amp; file_finder.File(),NULL);
+            // Do something with the full filename...
+            // ...
+            }
+        delete file_list;
+        err=file_finder.FindWild(file_list);
+        }
+    }</codeblock>
+<section id="GUID-0B6E41E7-C725-421D-9423-6CA77632E23F"><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>
\ No newline at end of file