Symbian3/PDK/Source/GUID-6F938BDA-15CB-566E-88E0-6DF9278F8304.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
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-6F938BDA-15CB-566E-88E0-6DF9278F8304"><title>How to get and change file details</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The <xref href="GUID-1F240E05-55D4-3161-B22E-B48D93A981DF.dita"><apiname>TEntry</apiname></xref> and <xref href="GUID-0355B083-6DD8-30F0-BEDF-B6BE745E2AB6.dita"><apiname>TEntryArray</apiname></xref> classes are used to store, retrieve, interrogate and sort directory entries. <codeph>TEntry</codeph> encapsulates a single directory entry and <codeph>TEntryArray</codeph> an array of directory entries. </p> <section><title>Retrieving entry details</title> <p>Use <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita#GUID-E263C747-946F-35AA-9F1D-41833BD350FC/GUID-58F5BAD5-0D8C-33C9-B93B-D1C48F53333A"><apiname>RFs::Entry()</apiname></xref> to retrieve the size of the file, its attributes, name and the date and time of its latest modification (if the file has not been modified, this will be the time of its creation). </p> <codeblock id="GUID-3FE04CB5-8305-54DC-9904-1882AB6035E2" xml:space="preserve">  // Get and print date/time and file size 
TBuf&lt;30&gt; dateString; 
TEntry entry;
User::LeaveIfError(fsSession.Entry(path,entry)); 
_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");
entry.iModified.FormatL(dateString,KDateString); 
_LIT(KModString, "Modification time of %S is %S\n"); // Format and print date and time
console-&gt;Printf(KModString, entry.iName,&amp;dateString); // Get file size
_LIT(KSizeString, "Size = %d bytes\n");
console-&gt;Printf(KSizeString,entry.iSize); </codeblock> <p><b>Notes</b> </p> <ul><li id="GUID-61C99E94-C6F9-582F-BF94-CCA57A53DC0E"><p>The time extracted using <codeph>TEntry::iModified</codeph> (and by <codeph>RFs::Modified()</codeph>) is an object of class <codeph>TTime</codeph>. Before a <codeph>TTime</codeph> value can be displayed, it must either be converted into its numeric fields (i.e., into a <codeph>TDateTime</codeph> object), or formatted, using <codeph>TTime::FormatL()</codeph>, as above. </p> </li> </ul> </section> <section><title>Changing attributes</title> <p>Use <xref href="GUID-E263C747-946F-35AA-9F1D-41833BD350FC.dita#GUID-E263C747-946F-35AA-9F1D-41833BD350FC/GUID-E1CB09AF-F5B0-35B2-B24E-C6F5F1C583C8"><apiname>RFs::SetAtt()</apiname></xref> to set a file or directory's attributes. It requires two attribute mask arguments. Any attributes specified in the first mask are set and any specified in the second are cleared. No attributes may be specified in both bitmasks. </p> <p>In the following example, the hidden and system attributes are set and the archive attribute is cleared. </p> <codeblock id="GUID-3C0120A7-7023-5967-A9C0-4ADB4483127B" xml:space="preserve">_LIT(KString,"%S");
User::LeaveIfError(fsSession.SetAtt(path,KEntryAttHidden|KEntryAttSystem,KEntryAttArchive)); </codeblock> </section> </conbody></concept>