Symbian3/SDK/Source/GUID-6F938BDA-15CB-566E-88E0-6DF9278F8304.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-6F938BDA-15CB-566E-88E0-6DF9278F8304" xml:lang="en"><title>How
to get and change file details</title><shortdesc>This topic describes how to get and change file details.</shortdesc><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 id="GUID-AD76D023-2328-453B-883D-6D1944D63CA5"><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 id="GUID-4D3B1F36-248E-4ACF-9E0D-B56FF56A4DD3"><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>