遍历Symbian某目录下的所有文件

遍历Symbian某目录下的所有文件应该是Symbian中常用到的功能模块,比如你想写一个类似“程序管理器”的程序,那么首先的任务就是要先知道某目录下到底有那些文件,然后再筛选出你所需要的文件。

遍历Symbian某目录下的所有文件有两种方法

① 我们首先学习点预备知识

查看SDK HELP中的GetDir()方法,你会看到如下的内容:

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 be listed. The sort key determines the order in which they are listed.

注释:

得到一个目录下内容的过滤列表。

anEntryAttMask决定哪个文件和目录应该被列出。

anEntrySortKey决定这些内容按照什么顺序列出。

Notes:

If sorting by UID (ESortByUid is OR'ed with the entry sort key), then UID information will be included in the listing whether or not KEntryAttAllowUid is specified in anEntryAttMask.(如果按照UID排序,即anEntrySortKey参数的值定义为ESortByUid。那么UID信息将被包含在列表中不管anEntryAttMask参数是否定义了KEntryAttAllowUid)

The function sets anEntryList to NULL, then allocates memory for it before appending entries to the list. Therefore, anEntryList should have no memory allocated to it before this function is called, otherwise this memory will become orphaned.(这个函数把anEntryList参数设置为NULL,然后在添加文件项到列表之前为anEntryList分配内存空间。因此,该函数调用之前anEntryList应该没有分配内存,否则这部分内存会变成垃圾而被遗弃)

The caller of this function is responsible for deleting anEntryList after the function has returned.(此函数的调用者有责任删除anEntryList在函数返回)

Parameters

const TDesC& aName

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

TUint anEntryAttMask

Bitmask indicating the attributes of interest. Only files and directories whose attributes match those specified here can be included in the listing. For more information see KEntryAttMatchMask and the other directory entry details. Also see KEntryAttNormal and the other file or directory attributes.

TUint anEntrySortKey

Flag indicating the order in which the entries are to be sorted. This flag is 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.

这是RFs类中的一个方法,从上面的SDK HELP内容我们可以看出:如果我们想获取某个目录下的所有内容,那么只需获取相应目录的CDir指针即可。

时间: 2024-09-16 05:07:29

遍历Symbian某目录下的所有文件的相关文章

用VC++遍历某一目录下的所有文件

#include "stdafx.h" #include "afx.h" #include "iostream.h" #include "winbase.h" int main(int argc, char* argv[]) { DWORD returnValue; if( SetCurrentDirectory("D:\\Code\\POS") == TRUE) { CFileFind finder; B

PHP遍历某个目录下的所有文件和子文件夹的实现代码

本篇文章是对PHP遍历某个目录下的所有文件和子文件夹的实现代码进行了详细的分析介绍,需要的朋友参考下   复制代码 代码如下: <?php function read_all_dir ( $dir ) { $result = array(); $handle = opendir($dir); if ( $handle ) { while ( ( $file = readdir ( $handle ) ) !== false ) { if ( $file != '.' && $file

linux shell 遍历指定目录下的所有文件夹

在linux 中,如何遍历指定目录下的所有文件夹呢? 要求能搜索结果中包含隐藏文件夹 脚本名:ergodic_folder.sh 脚本内容: Shell代码   #!/bin/sh   list_alldir(){       for file2 in `ls -a $1`       do           if [ x"$file2" != x"." -a x"$file2" != x".." ];then       

目录名称-递归遍历指定目录下的所有文件,依次按目录的名称与文件的名称排序

问题描述 递归遍历指定目录下的所有文件,依次按目录的名称与文件的名称排序 递归遍历指定目录下的所有文件,按依次按目录的名称与文件排序, 首先同一级目录的按目录名称排序,然后按文件的名称排序. 思路一:递归获取到所有文件后,根据件的全路径作在比较器中比较排序(file0.getAbsolutePath().compareTo(file1.getAbsolutePath())),这样可能不会很准.. 求大神支招啊! 想要的排序结果如下: d:/update/spc333/1/aa.txt d:/up

Linux shell编程 5 ---- 利用shell脚本遍历某个目录下的所有文件

 1 我们都知道shell脚本能够做很多的事,今天刚好一个队友要我写个脚本求某个目录下所有java文件的行数总和  2 ok,为了方便,我把这个目录放到了当前的家目录下,路径为/home/chenguolin/src  3 我在家目录下建了一个s.sh的脚本,代码如下,等等来分析代码的意思 #!/bin/bash function ergodic(){ for file in ` ls $1 ` do if [ -d $1"/"$file ] then ergodic $1"

获取某目录下的所有文件(包括子目录下文件)的数量(C#)

以前写过一个通过计算目录遍历所有文件和子目录的方法来获得某目录下的文件个数,结果发现速度极慢,远远不及系统本身目录属性里边显示的速度. int fileNum = 0;/**//// <summary>/// 获取某目录下的所有文件(包括子目录下文件)的数量/// </summary>/// <param name="srcPath"></param>/// <returns></returns>public in

查找目录下的所有文件中是否含有某个字符串 linux

查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xargs grep -ri "IBM" -l 1.正则表达式    (1)正则表达式一般用来描述文本模式的特殊用法,由普通字符(例如字符a-z)以及特殊字符(称为元字符,如/.*.?等)组成.   (2)基本元字符集及其含义       ^ :只匹配行首.   如^a 匹配以a开头的行abc,

python将某目录下所有excel文件合并教程

一.需求 公司要求把从16年1月1日到当前的所有处理事件合并 ,简单的理解就是把所有的日报合并到一个表格中呗.刚好16所有的日报都保留在一个文件夹中了,这里通过python + xlrd(读) + xlsxwriter(写) 实现把所有的日志汇总到一个excel 文件中 .这里没有用xlwt模块进行写操作,由于目前主流使用的office基本都2007以后的了,所以xlsxwriter支持相对更好些. 原日报的格式如下: 需要汇总如下格式 二.python实现 先上代码: [root@361way

php查找指定目录下指定大小文件的方法_php技巧

本文实例讲述了php查找指定目录下指定大小文件的方法.分享给大家供大家参考.具体实现方法如下: php查找文件大小的原理是遍历目录然后再利用filesize来计算文件大小,然后我们再加一判断就可以了,下面整理了一些例子. 我们先来看遍历目录,代码如下: 复制代码 代码如下: function tree($directory)  {   $mydir = dir($directory);   echo "<ul>n";   while($file = $mydir->r