Symbian3/SDK/Source/GUID-EAEE54D0-4580-5BE7-AA16-4ABC216B4EB0.dita
changeset 7 51a74ef9ed63
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-EAEE54D0-4580-5BE7-AA16-4ABC216B4EB0.dita	Wed Mar 31 11:11:55 2010 +0100
@@ -0,0 +1,61 @@
+<?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-EAEE54D0-4580-5BE7-AA16-4ABC216B4EB0" xml:lang="en"><title>How
+to list directories and files</title><shortdesc>This topic describe show to list directories and files together
+and separately.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>The list of a directory's contents can obtained by using two variants of
+the function <codeph>RFs::GetDir()</codeph>. Both variants provide a filtered
+list of files and directories; the second additionally provides a separate
+list containing directories only. Both variants use an attribute mask to filter
+the entry types. </p>
+<p>The following sections assume that some directories and a file have been
+created in a directory <filepath>FileserverExample</filepath>, and then lists
+them in alphabetical order.</p>
+<section id="GUID-75A55F3B-D29B-48D3-B4DB-D907FA8F29E7"><title>Listing directories and files together</title> <ol id="GUID-EF43DF74-3059-50A2-854A-59985457877B">
+<li id="GUID-5781228A-BDB8-5E80-AFFF-9B0CB1E574A9"><p>Declare a <codeph>CDir</codeph> pointer.
+This type holds an array of directory entries.</p> </li>
+<li id="GUID-184CBE11-E62C-542F-9F95-718960F72639"><p>Use <codeph>GetDir()</codeph> to
+get a single list, in the <codeph>CDir</codeph> object, which can contain
+both file and directory entries.</p> <p>Use <codeph>KEntryAttMaskSupported</codeph> to
+indicate all five file attributes, and the directory attribute.</p> <p>Use <codeph>ESortByName</codeph> to
+order the entries alphabetically.</p> </li>
+<li id="GUID-3AD0DD32-B772-5B9B-A3BF-32DAC34D00E3"><p><codeph>CDir::operator[]()</codeph> can
+be used to get the attributes, name, size and modification date and time of
+the <codeph>TEntry</codeph> at the specified index within the array. </p> </li>
+<li id="GUID-BCD0DB7B-8329-5C3F-B194-68D77FB1C9C5"><p>Delete the <codeph>CDir</codeph> object
+after use.</p> </li>
+</ol> <codeblock id="GUID-5C104BEF-855C-55F3-8648-3DB6285A3607" xml:space="preserve">
+_LIT(KDir,"\\FileserverExample\\*");
+CDir* dirList;
+User::LeaveIfError(fsSession.GetDir(KDir,
+        KEntryAttMaskSupported,ESortByName,dirList));
+_LIT(KString,"%S");
+for (TInt i=0;i&lt;dirList-&gt;Count();i++)
+    console-&gt;Printf(KString,&amp;(*dirList)[i].iName);
+delete dirList;</codeblock> <p><b>Notes</b> </p> <ul>
+<li id="GUID-6BACC898-1046-52BF-9338-445C4685DFA6"><p><codeph>GetDir()</codeph> supports
+the use of the two <keyword>wildcard</keyword> characters: <filepath>*</filepath> (meaning
+any sequence of characters within any part of a component), and <filepath>?</filepath> (meaning
+any single character).</p> </li>
+</ul> </section>
+<section id="GUID-C3AE6F4F-C1E4-4F37-B638-ABC952E6D5BD"><title>Listing directories and files separately</title> <p>If you
+want files and directories to be listed separately, another variant of <codeph>GetDir()</codeph> should
+be used. On return, the first list contains only files, the second directories.</p> <ol id="GUID-EE1E3D1B-109C-50B4-814F-1AA37105E8DE">
+<li id="GUID-ACE8E30C-3784-552F-B2F1-8A5C7ACE52CA"><p>Use <codeph>GetDir()</codeph> to
+provide a list of directories and files and additionally a separate list of
+directories only.</p> </li>
+<li id="GUID-5B68A082-7725-5F05-BCB0-2B8513803001"><p>If the attribute mask <codeph>KEntryAttNormal</codeph> is
+used, no system or hidden files or directories are included in the file list.</p> </li>
+</ol> <codeblock id="GUID-E8D48A34-62EA-588C-9B10-36B87CCF27D6" xml:space="preserve">CDir* fileList;
+User::LeaveIfError(fsSession.GetDir(KDir,
+        KEntryAttNormal,ESortByName,fileList,dirList));</codeblock> </section>
+</conbody></concept>
\ No newline at end of file