<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>
遍历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指针即可。
那么我们再看看CDir这个类的SDK HELP:
Class CDir
CDir Support Supported from 5.0 Description Array of directory entries that has been read into memory from the file system— abstract base class. It can be read and sorted by user programs, but cannot be created by them. This class is not intended for user derivation. 注释:一个数组,这个数组的内容是从文件系统扫描到的目录,目录被缓存到内存中。它可以被我们的程序读取和排序,但是不能创建。 Derivation o CBase - Base class for all classes to be instantiated on the heap § CDir - Array of directory entries that has been read into memory from the file system— abstract base class Members Defined in CDir :
Count() , NewL() , Sort() , operator[]() , ~CDir() Inherited from CBase :
operator new() 可见,这个类派生自CBase,并且继承了CBase的new()运算符。它里面只有5个方法,去处析构函数,实际上只有4个有用的方法。并且它里面重新定义了[]操作符,因为CDir本身是一个目录的数组。它还可以排序、可以计算数量,这些都是数组的基本特性。NewL()只不过也是一个重载的运算符而已。 再看看operator[]()的定义: operator[]() const TEntry& operator[](TInt anIndex) const; Description Returns an entry from the array. Parameters
TInt anIndex | Index of the desired entry within the array. |
|
Return value
TEntry& | A directory entry. |
|
可以看出,通过[]操作符,CDir指针返回给我们的是一个目录的封装类 TEntry。
|
我们可以再跟踪一下TEntry这个类的SDK HELP:
Class TEntry
TEntry Support Supported from 5.0 Description Encapsulates an entry in a directory, which can be another (nested) directory, a file or a volume label. Each directory entry has a name which is relative to its owning directory and a type, which is indicated by its unique identifier (UID). 注释:封装目录中的一项内容,内容可以是另一个(嵌套的)目录、一个文件或者是一个驱动器卷标。每个目录项都有一个名字和类型与它的所属目录相关联,也就是UID所显示出来的东西。 An entry can be interrogated for the following properties: 一项内容可以被提取以下的属性: · the kind of entry: stored in the entry UIDs, stored in iType (项的类型:储存在UIDs和iType中) · the entry attributes, stored in iAtt (项的属性:储存在iAtt中) · the size of entry(项的尺寸) · the time the entry was last modified(项上次被修改的时间) Members Defined in TEntry :
IsArchive() , IsDir() , IsHidden() , IsReadOnly() , IsSystem() , IsTypeValid() , IsUidPresent() , MostDerivedUid() , iAtt , iModified , iName , iSize , iType , operator[]() See also:
|
通过以上SDK HELP的内容,我们就知道了大概的方向,从而尝试写出了以下的程序:
void CCountEntryAppUi::ConstructL()
{
BaseConstructL();
RFs iFs;
User::LeaveIfError(iFs.Connect());
_LIT(KDIR,"C:\\");
CDir* dir;
User::LeaveIfError(iFs.GetDir(KDIR,KEntryAttNormal|KEntryAttMatchMask,ESortByDate,dir));
TInt tempInt = dir->Count();
for(int i = 0;i
{
TEntry& iEntry = (TEntry&)dir[i];
TBufC iFileName = iEntry.iName;
}
delete dir;
dir = NULL;
iAppContainer = new (ELeave) CCountEntryContainer;
iAppContainer->SetMopParent( this );
iAppContainer->ConstructL( ClientRect() );
AddToStackL( iAppContainer );
}
通过设置断点进行观察,可以看到如下结果:

<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 2in; HEIGHT: 192pt" type="#_x0000_t75"><imagedata src="file:///C:%5CDOCUME~1%5Cuser%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.png" o:title="1"></imagedata></shape>
而Symbian系统C盘下的文件内容如下:

<shape id="_x0000_i1026" style="WIDTH: 2in; HEIGHT: 192pt" type="#_x0000_t75"><imagedata src="file:///C:%5CDOCUME~1%5Cuser%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image003.png" o:title="2"></imagedata></shape>
可见,此时程序所读取到的文件数目是正确的。
② 下面我们来看第二中获取Symbian某目录下所有文件的方法,其基本原理是类似的,只不过是调用了不同的接口而已。
RFs iFs;
User::LeaveIfError(iFs.Connect());
_LIT(KDIR,"C:\\");
RDir oDir;
oDir.Open(iFs, KDIR, KEntryAttNormal);
TEntryArray* oArray = new (ELeave) TEntryArray;
oDir.Read(*oArray);
TInt iCount = oArray->Count();
for(TInt i = 0;i
{
TEntry temp = (*oArray)[i];
TName iTemp = temp.iName;
if(i == 2)
CEikonEnv::Static()->InfoMsg(iTemp);
}
iFs.Close();
和第一种方法不同的是,这里使用了RDir类作为目录项的存放数组。我们看看SDK HELP中这个类的帮助文档:
RDir Support Supported from 5.0 Description Reads the entries contained in a directory. 读取一个目录中所包含的项,包括目录、文件以及驱动器卷标,这一点和上面的CDir类是一样的。 You must first open the directory, specifying an attribute mask which is used by Read() calls to filter the entry types required. Then, use one of the Read() functions to read the filtered entries. When the operation is complete, the directory should be closed using Close(), defined in the base class RFsBase. 你必须先打开目录,定义一个属性掩码用来过滤项类型。然后用Read()函数去读取过滤的项。当操作完成时,目录应该调用基类RFsBase中定义的Close()方法关闭。 There are two types of Read(): one works with a single entry at a time, requiring programs to iterate through the entries explicitly. The other works with an entire TEntryArray, allowing multiple entries to be read in one call. As well as making application program logic somewhat simpler, this type uses fewer calls to the server, and is more efficient. 有两种版本的Read()方法:一种是每次读取一个目录项,要求遍历所有目录项。另一种利用一个TEntryArray工作,它允许多个目录项一次读取完。为了让应用程序逻辑简单,这种类型和服务器的交互少,并且非常高效。 Each type of Read() can be performed either synchronously or asynchronously. 每种版本的Read()方法都可以表现为同步的或者异步的。 It may be more convenient to use RFs::GetDir() than the Read() calls supported by this class. RFs::GetDir() has the advantage that it allows a directory's entries to be sorted in various ways. However, it does not provide asynchronous as well as synchronous variants and does not allow entries to be read individually. RFs::GetDir()比这个类所提供的方法更方便,而且RFs::GetDir()允许一个目录的项以不同的方式排序。尽管如此,RFs::GetDir()却不区分同步、异步的方式,并且不允许目录项逐个的读取。 Derivation
-
RSubSessionBase - Client-side handle to a sub-session
-
RFsBase - Base class that provides a Close() function for file related clean-up
-
RDir - Reads the entries contained in a directory
Members Defined in RDir: Open(), Open(), Read(), Read(), Read(), Read() Inherited from RFsBase: Close() Inherited from RSubSessionBase: CloseSubSession(), CreateSubSession(), Send(), SendReceive(), SubSessionHandle(), operator=() |
看到这里,再和第一种方法进行比较,就应该很容易明白开头所给出的代码了,这段代码在VS2003+Carbide.vs+ S60_2nd_FP2_SC SDK中也编译通过.
相关推荐
这一逻辑可以通过遍历`iTileState`数组来实现,检查是否所有的非雷格子都被正确揭示。 #### 四、标记雷与错误标记处理 标记雷的功能允许玩家在不确定某格子是否有雷时进行标记,以供后续判断。错误标记处理则是在...
qt 一个基于Qt Creator(qt,C++)实现中国象棋人机对战.
热带雨林自驾游自然奇观探索
冰川湖自驾游冰雪交融景象
C51 单片机数码管使用 Keil项目C语言源码
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
前端分析-2023071100789s12
Laz_制作了一些窗体和对话框样式.7z
1、文件内容:ocaml-docs-4.05.0-6.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/ocaml-docs-4.05.0-6.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊
学习笔记-沁恒第六讲-米醋
工业机器人技术讲解【36页】
内容概要:本文档详细介绍了在 CentOS 7 上利用 Docker 容器化环境来部署和配置 Elasticsearch 数据库的过程。首先概述了 Elasticsearch 的特点及其主要应用场景如全文检索、日志和数据分析等,并强调了其分布式架构带来的高性能与可扩展性。之后针对具体的安装流程进行了讲解,涉及创建所需的工作目录,准备docker-compose.yml文件以及通过docker-compose工具自动化完成镜像下载和服务启动的一系列命令;同时对可能出现的问题提供了应对策略并附带解决了分词功能出现的问题。 适合人群:从事IT运维工作的技术人员或对NoSQL数据库感兴趣的开发者。 使用场景及目标:该教程旨在帮助读者掌握如何在一个Linux系统中使用现代化的应用交付方式搭建企业级搜索引擎解决方案,特别适用于希望深入了解Elastic Stack生态体系的个人研究与团队项目实践中。 阅读建议:建议按照文中给出的具体步骤进行实验验证,尤其是要注意调整相关参数配置适配自身环境。对于初次接触此话题的朋友来说,应该提前熟悉一下Linux操作系统的基础命令行知识和Docker的相关基础知识
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
网络小说的类型创新、情节设计与角色塑造
毕业设计_基于springboot+vue开发的学生考勤管理系统【源码+sql+可运行】【50311】.zip 全部代码均可运行,亲测可用,尽我所能,为你服务; 1.代码压缩包内容 代码:springboo后端代码+vue前端页面代码 脚本:数据库SQL脚本 效果图:运行结果请看资源详情效果图 2.环境准备: - JDK1.8+ - maven3.6+ - nodejs14+ - mysql5.6+ - redis 3.技术栈 - 后台:springboot+mybatisPlus+Shiro - 前台:vue+iview+Vuex+Axios - 开发工具: idea、navicate 4.功能列表 - 系统设置:用户管理、角色管理、资源管理、系统日志 - 业务管理:班级信息、学生信息、课程信息、考勤记录、假期信息、公告信息 3.运行步骤: 步骤一:修改数据库连接信息(ip、port修改) 步骤二:找到启动类xxxApplication启动 4.若不会,可私信博主!!!
在智慧城市建设的大潮中,智慧园区作为其中的璀璨明珠,正以其独特的魅力引领着产业园区的新一轮变革。想象一下,一个集绿色、高端、智能、创新于一体的未来园区,它不仅融合了科技研发、商业居住、办公文创等多种功能,更通过深度应用信息技术,实现了从传统到智慧的华丽转身。 智慧园区通过“四化”建设——即园区运营精细化、园区体验智能化、园区服务专业化和园区设施信息化,彻底颠覆了传统园区的管理模式。在这里,基础设施的数据收集与分析让管理变得更加主动和高效,从温湿度监控到烟雾报警,从消防水箱液位监测到消防栓防盗水装置,每一处细节都彰显着智能的力量。而远程抄表、空调和变配电的智能化管控,更是在节能降耗的同时,极大地提升了园区的运维效率。更令人兴奋的是,通过智慧监控、人流统计和自动访客系统等高科技手段,园区的安全防范能力得到了质的飞跃,让每一位入驻企业和个人都能享受到“拎包入住”般的便捷与安心。 更令人瞩目的是,智慧园区还构建了集信息服务、企业服务、物业服务于一体的综合服务体系。无论是通过园区门户进行信息查询、投诉反馈,还是享受便捷的电商服务、法律咨询和融资支持,亦或是利用云ERP和云OA系统提升企业的管理水平和运营效率,智慧园区都以其全面、专业、高效的服务,为企业的发展插上了腾飞的翅膀。而这一切的背后,是大数据、云计算、人工智能等前沿技术的深度融合与应用,它们如同智慧的大脑,让园区的管理和服务变得更加聪明、更加贴心。走进智慧园区,就像踏入了一个充满无限可能的未来世界,这里不仅有科技的魅力,更有生活的温度,让人不禁对未来充满了无限的憧憬与期待。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
内容概要:本文介绍了使用 Matlab 实现基于 BO(贝叶斯优化)的 Transformer 结合 GRU 门控循环单元时间序列预测的具体项目案例。文章首先介绍了时间序列预测的重要性及其现有方法存在的限制,随后深入阐述了该项目的目标、挑战与特色。重点描述了项目中采用的技术手段——结合 Transformer 和 GRU 模型的优点,通过贝叶斯优化进行超参数调整。文中给出了模型的具体实现步骤、代码示例以及完整的项目流程。同时强调了数据预处理、特征提取、窗口化分割、超参数搜索等关键技术点,并讨论了系统的设计部署细节、可视化界面制作等内容。 适合人群:具有一定机器学习基础,尤其是熟悉时间序列预测与深度学习的科研工作者或从业者。 使用场景及目标:适用于金融、医疗、能源等多个行业的高精度时间序列预测。该模型可通过捕捉长时间跨度下的复杂模式,提供更为精准的趋势预判,辅助相关机构作出合理的前瞻规划。 其他说明:此项目还涵盖了从数据采集到模型发布的全流程讲解,以及GUI图形用户界面的设计实现,有助于用户友好性提升和技术应用落地。此外,文档包含了详尽的操作指南和丰富的附录资料,包括完整的程序清单、性能评价指标等,便于读者动手实践。
漫画与青少年教育关系