Traverse all files in a directory of Symbian

Source: Internet
Author: User
Tags bitmask sort

If you want to write a program that looks like a program manager, the first thing you need to do is to know what files are in a directory and then filter out the files you're looking for, as you'll find all the files in Symbian's directory.

There are two ways to traverse all the files in a directory of Symbian

① We first learn some preliminary knowledge

Looking at the Getdir () method in the SDK help, you will see the following:

Getdir ()

TInt getdir (const tdesc& aname,tuint anentryattmask,tuint Anentrysortkey, cdir*& anentrylist) const;

Description

Gets a filtered list of a directory ' s contents. The bitmask determines which file and directory entry types should is listed. The sort key determines the order in which they are listed.

Comments:

Gets a filtered list of contents under a directory.

Anentryattmask determines which files and directories should be listed.

Anentrysortkey determines in what order these contents are listed.

Notes:

If sorting by UID (Esortbyuid are OR ' ed with the entry sort key), then UID information would be included in the listing whet Her or not kentryattallowuid are specified in Anentryattmask. (If you sort by uid, that is, the value of the Anentrysortkey parameter is defined as Esortbyuid.) Then the UID information will be included in the list regardless of whether the Anentryattmask parameter defines Kentryattallowuid.

The function sets Anentrylist to NULL, then allocates memory for it before appending to the list. Therefore, Anentrylist should have no memory allocated to it before the This function are called, otherwise this memory would be Come orphaned. (This function sets the anentrylist parameter to null and then allocates the memory space for Anentrylist before adding the file entry to the list.) Therefore, before the function is called, the anentrylist should not allocate memory, otherwise this part of memory will become garbage and abandoned.

The caller of this function is responsible to deleting anentrylist after the function has returned. (The caller of this function is responsible for removing anentrylist in function return)

Parameters

Const tdesc& Aname

Name of the directory for which a listing is required. Wildcards May is used to specify particular files.

Tuint Anentryattmask

Bitmask indicating the attributes of interest. Only files and directories whose attributes match those specified is the can is included in the listing. For more information-Kentryattmatchmask and the other directory entry details. Also the Kentryattnormal and the other file or directory attributes.

Tuint Anentrysortkey

Flag indicating the order of which the entries are to be sorted. This flag was defined in Tentrykey.

cdir*& anentrylist

On return contains a list of directory and file entries.

return value

TInt

Kerrnone if successful, otherwise another of the System-wide error codes.

This is a method in the RFS class, which we can see from the SDK Help content above: if we want to get all the content in a directory, we just need to get the Cdir pointer to the corresponding directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.