This topic describes the common concepts of file systems and files used by Symbian platform.
Like other software systems, Symbian platform can store data so that it is kept when a handset is powered down.
On PCs, a file is kept on magnetic disk or optical media such as CD or DVD. On older generations of personal organisers, a file was often kept in RAM, needing a permanent power supply, and a backup battery to guarantee this. On the most recent telephone handsets, files are normally stored in flash memory, either NOR flash or NAND flash, and also on removable devices such as MultiMediaCard (MMC), Secure Digital card (SD card), Memory Stick or Compact flash (CF).
There are more sophisticated services for persisting data such as streams, stores, central repository etc. that applications can use, but they all rely, either directly or indirectly, on the commonly understood idea of the file.
The ROM on a typical handset is located in non-volatile flash memory, allowing it to be upgraded by the handset manufacturer after initial production. The location for user data is almost always flash memory (NAND or NOR), on the grounds of cost, although rotating media devices capable of holding large amounts of data are likely in future handsets.
Symbian platform uses a number of file concepts that are common to most operating systems, for example, drives and directories.
Drives
Symbian platform uses the concept of the drive . This idea is similar to that in other operating systems, i.e. it corresponds to a logical device. A media device such as a MultiMediaCard can be logically split into partitions, and each partition is treated as a separate drive. Symbian platform adopts a DOS-like convention where each drive is identified by a single letter. This means that there can be up to 26 drives on a handset, identified by the letters A: through to Z: . In practice, there are far fewer than this, and the number depends on the individual manufacturer's handset
Internally, Symbian platform uses the idea of a drive number instead of a letter, and some legacy API items take a drive number as input, or return a drive number as output. However, there are functions that can translate drive numbers to and from drive letters: RFs::DriveToChar() and RFs::CharToDrive() .
The main ROM on a handset is always identified as the Z: drive. Other drives may be in use: sixteen of the drives C: to R: are usually reserved as local drives, i.e. for media devices located within the handset. A common convention is to adopt C: as the main user data drive. and to designate D: or E: as drives for removable media. Be aware , however, that this is a convention that some handset manufacturers may not follow, so you are always advised to check the full SDK that applies to a specific handset for guidance. Indeed, as a matter of principle, you should always use the system drive for user data.
Volume
The concept of the volume applies to removable media. As users insert and remove individual devices, so different volumes are said to be mounted and demounted. For media types that can be split into partitions, each partition corresponds to a separate volume.
File names and directory structures
Files have names, and Symbian platform uses a hierarchical directory structure in which to organize them; this is similar to schemes adopted by other operating systems. For example:
C:\AAA\BBB\CCC\DDD.EXT
There are four main parts to the structure:
the drive ; this is always at the top of the hierarchy, and is represented by a drive letter and a colon.
the path ; this is a list of names, each name representing a level in the hierarchy. Each directory name is separated by a back slash character, and the last directory name is always terminated by a back slash character.
the filename ; this is everything after the final backslash, and before the dot if there is a file extension. Symbian platform supports long file filenames.
the extension , everything after the final dot. There is no restriction on the length of the extension; limits on length apply to the whole structure, not to any single part of it.
You will find that the whole structure is sometimes referred to as the full file name or the full path name. The maximum length of a full file name is limited to 256 characters. Symbian platform does not use the extension to identify the software or application that can access the data. Instead, files have UIDs embedded within them, and the mapping of files to applications is done through these UIDs. For more information, see Symbian^3 Tools Guide > Building .
The case of full path names is always preserved, but operations on names are case insensitive. This means that two files that have the same name but differ only in case are considered to refer to the same file.
Full file names are normally manipulated programmatically. Extracting drive names, filenames, file extensions, and changing the names of a directory structure are typical activities. Symbian platform provides you with the TParse , TParsePtr , and TParsePtrC classes to help you do this manipulation.
On Symbian platform, file services are a common resource. Like other common or shared resources on Symbian platform, file services are handled by a server - the file server. Applications and other software that require access to files, directories and drives are clients of the file server, and send file-related requests using the file server client-side API .
The file server is multithreaded, which allows each logical drive to be accessed concurrently. More than one request can be issued for the same drive, but these requests are handled sequentially. For example, a request to read or write data to a MultiMediaCard can be handled at the same time as a request to read or write data to the main user drive.
The file server has a main thread that initially handles all requests. Short requests, such as those that require access to the ROM drive, and those that do not require access to any media, run in the file server.
The services provided by the file server can be divided into two types:
those that give you access to individual files, directories and drives using the RFile , RDir and RFormat classes.
See also How to use sessions, files, and directories .
those that allow you to do higher level longer running operations such as moving, copying and deleting files, using the CFileMan class, scanning directory trees using the CDirScan class, and tracking the progress of these operations using the MFileManObserver class.
See also File management and searching .
Like most other servers, the client API allows you to make file requests synchronously or asynchronously.
See also client-server .
Security considerations restrict the parts of a handset's directory structure that an application is allowed to access. The concept is referred to as data caging .
There are a number of principles involved:
The fundamental principle is the separation of executable code from data. Executable code can only reside in the /sys/bin/ directory. Executables cannot be loaded from any location other than /sys/bin/ . Unless an application has the appropriate system capabilities, the /sys/ directory is not visible to that application. System capabilities are a discrete set of 'permissions' that give access to various sensitive system services, and which can only be granted to applications, if justified, through the Symbian Signed scheme.
Applications have their own private directory, under which they are free to create further directory structures and files, and to write to those files. This is the directory structure /private/<app_SID>/ . <app_SID> is known as a secure identifier and, in general, is used when verifying an executable's rights of access to system resources. Here, it is used to form the path name for the executable's private directory. The secure identifier is a UID which is allocated to a developer through the Symbian Signed scheme, and is guaranteed to be unique within the handset on which the application is installed. The UID is coded into the mmp file(s) that define the application's source files, link requirements, and general characteristics.
Other applications have no right of access to an application's private directory.
There is a directory /resource/ to which all applications have read access, but no write access. The purpose of this directory is to conatin common read-only files.
All other directories are accessible for both reading and writing. This allows the use of standard file system hierarchies that may be available on removable media.
The above principles apply regardless of the drive.
It is possible to pass an open file to another process, or between a client and server, so that the target can access the file without knowing the full path name. The only information that is passed to the target is the filename and extension.
The varying characteristics of media types can mean that different media types require different formats. A common format is VFAT, and typically, this is used for removable media to maintain compatibility with other systems. This also means that long file names are supported.
In Symbian platform, format schemes are implemented by what are called file systems; they are constructed as plugins to the file server. This means that the file server itself is independent of the format scheme, and also means that a phone manufacturer is free to add new file systems to a handset. The ROM is an exception - it has its own file system built into the main file server code.
A file system must be associated with a drive before the drive can be used. This is known as mounting the drive, and is typically done at system boot time.
In practice, an application does not need to concern itself with the format scheme.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.