|
||
The TEntry
and TEntryArray
classes are used to store, retrieve, interrogate and sort directory entries.
TEntry
encapsulates a single directory entry and
TEntryArray
an array of directory entries.
Use RFs::Entry()
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).
// Get and print date/time and file size
TBuf<30> 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->Printf(KModString, entry.iName,&dateString); // Get file size
_LIT(KSizeString, "Size = %d bytes\n");
console->Printf(KSizeString,entry.iSize);
The time extracted using TEntry::iModified
(and by
RFs::Modified()
) is an object of class TTime
. Before
a TTime
value can be displayed, it must either be converted into
its numeric fields (i.e., into a TDateTime
object), or formatted,
using TTime::FormatL()
, as above.
Use RFs::SetAtt()
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.
In the following example, the hidden and system attributes are set and the archive attribute is cleared.
_LIT(KString,"%S");
User::LeaveIfError(fsSession.SetAtt(path,KEntryAttHidden|KEntryAttSystem,KEntryAttArchive));