在Symbian OS中,Flash(闪存)通常被定义为C盘。另外,在Symbian智能手机中还有一个ROM存储器,通常被映射为Z盘,用户的许多文件存放在Z盘中,其他可移动存储器(如存储卡等)则映射为d,e等盘符。 应用程序要对文件进行读写,必须使用文件服务器提供的各种读写函数。在使用这些函数前,必须建立应用程序与文件服务器的连接,这种连接称为会话(session)。Symbian OS提供了RFs类,该类的Connect()/Close()函数用来建立和关闭连接。应用程序和文件服务器建立连接的具体过程如下:
常用的驱动器操作: enum TDriveNumber enum TFileMode /* The attributes of the media mounted on the drive. Replaced with: For more information see RFs中与驱动器操作相关的方法: 目录操作主要包括建立一个目录或目录结构、访问目录的属性等。在进行目录操作之前仍然先与文件服务器进行连接。 RFs中常用的文件/目录操作方法如下: TInt MkDir(const TDesC& aPath); Makes a directory. It should be a sub-directory of an existing directory and its name should be unique within its parent directory, otherwise the function returns an error. TInt MkDirAll(const TDesC& aPath); Makes one or more directories. Any valid path component specified in the specified path which does not already exist is created as a directory. TInt RmDir(const TDesC& aPath); Note that if a filename is specified in the argument, it is ignored. Therefore, there should be a trailing backslash after the final directory name in the argument to indicate that it is a directory, not a filename. TInt Delete(const TDesC& aName); Deletes a single file. Wildcards are not allowed in either the file name or the extension, otherwise an error is returned. TInt Rename(const TDesC& anOldName,const TDesC& aNewName); Renames a single file or directory. It can also be used to move a file or directory by specifying different destination and source directories. If so, the destination and source directories must be on the same drive. If a directory is moved, then the directory structure beneath it is also moved. If a directory specified by TInt Replace(const TDesC& anOldName,const TDesC& aNewName); Replaces a single file with another. This function does not support the use of wildcards. Unlike TInt Att(const TDesC& aName,TUint& aAttValue) const; Returns a file's attributes. TInt SetAtt(const TDesC& aName,TUint aSetAttMask,TUint aClearAttMask); Sets or clears the attributes of a single file.The function uses two bitmasks. The first bitmask specifies the attributes to set. The second specifies the attributes to clear. TInt Modified(const TDesC& aName,TTime& aTime) const; Gets the last modification date and time of a file or directory. If there has been no modification, the function gets the date and time of the file or directory's creation. TInt Entry(const TDesC& aName,TEntry& anEntry) const; Gets the entry details, including UID information, for a file or directory. TInt SetModified(const TDesC& aName,const TTime& aTime); Sets the date and time that the contents of a file or directory were modified. TInt SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); Sets both the attributes and the last modified date and time for a file or directory.The function uses two bitmasks. The first bitmask determines which attributes should be set. The second bitmask determines which are cleared. TInt RealName(const TDesC& aName,TDes& aResult) const; Gets the real name of a file.This is used in circumstances where a file system needs to mangle Symbian OS natural names so that it can store them on that file system. TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList) const; 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. TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList,CDir*& aDirList) const; Gets a filtered list of the directory and file entries contained in a directory and a list of the directory entries only. The bitmask determines which file and directory entry types should be listed in TInt GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey, CDir*& aFileList) const; Gets a filtered list of a directory's contents by UID.The TInt DefaultPath(TDes& aPath) const; Gets the system default path. This path is assigned as the session path to new clients when they connect to the file server. There is a single system default path rather than one for each drive. TInt SetDefaultPath(const TDesC& aPath); Sets the system default path. This path is assigned as the session path to new clients when they connect to the file server. The session paths of existing clients remain unchanged. There is a single system default path rather than one for each drive. TInt SessionPath(TDes& aPath) const; Gets the session path. When a client connects to the file server, its session path is initialised to the system default path. The session path of an existing client can only be changed by TInt SetSessionPath(const TDesC& aPath); Sets the session path for the current file server client. When the client first connects to the file server, its session path is initialised to the system default path. |