03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

F32 supports the addition of new file system drivers, either for networked drives or for new<br />

media types. Drivers may be added dynamically, without rebooting and without interrupting<br />

any connected file server sessions.<br />

Media configuration is an important variable of Symbian OS. For example, the Psion Revo<br />

doesn't support removable media and the Nokia 7650 uses a very small flash drive as c: for<br />

temporary file storage, whereas its d: drive corresponds to its main internal flash-based<br />

media.<br />

However, it's always safe to assume that a Symbian OS phone has a read-only z: drive and<br />

a read/write c: drive.<br />

13.3.4 Files<br />

An open file is represented by an RFile object. You can open a file with one of four RFile<br />

functions, each of which takes an RFs so that the RFile has a session within which to<br />

communicate with the server. The 'open' functions are:<br />

� Open(), which opens an existing file for either reading or writing.<br />

� Create(), which creates a new file for writing.<br />

� Replace(), which deletes an existing file and creates a new one for writing.<br />

� Temp(), which opens a temporary file and allocates a name to it.<br />

When you've opened a file, you can Read() from it into a TDes8 or Write() to it from a<br />

TDesC8. You can also Seek() to a position and Flush() any server-side write buffers to<br />

the file.<br />

Various access modes are supported: shared read, exclusive write, or shared write.<br />

Operations are blocked if they violate the access and sharing modes on a file. You normally<br />

specify the access mode when you open the file, although you can change it while the file is<br />

open using ChangeMode(). If you're using shared write access, you can use Lock() to<br />

claim temporary exclusive access to regions of the file and then UnLock() it later.<br />

Moreover, while the file is open, you can change its name using Rename().<br />

Later we will see examples of opening, reading, and writing. If you're interested in more<br />

details on the other functions, see the SDK.<br />

13.3.5 Directories<br />

A directory contains files and other directories each of which is represented by a directory<br />

entry or simply, in file server API language, an entry.<br />

The RDir class allows you to iterate through all the entries in a directory, while the TEntry<br />

type is used to contain a single entry.<br />

It's expensive to call the file server once for each directory entry, so RFs provides high-level<br />

GetDir() functions that get more than one entry into a CDir.<br />

You can change attributes of directory entries, including the hidden, system, read-only, and<br />

archive bits. The only bit with a really unambiguous meaning is read-only. If a file is specified<br />

as read-only, then you won't be able to write to it or erase it.<br />

Hidden files are optionally hidden by some higher-level components. System files are<br />

optionally hidden by some higher-level components. These attributes are supported for strict<br />

compatibility with VFAT, but usage conventions in the PC world are confused and they aren't

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!