Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: f32file.h

Enum TFileMode

TFileMode

Support

Supported from 5.0

Description

Access and share modes available when opening a file.

The access mode indicates whether the file is opened for reading only or writing. The share mode indicates whether other RFile objects can access the open file, and whether this access is read only.

If a file is already open for sharing, it can only be opened by another program using the same share mode as the one in which it was originally opened. For example, a file opened using EFileShareReadersOnly share mode can only be opened by another program using EFileShareReadersOnly mode.

So, to open a file for reading and writing with read and write shared access, use:

_LIT(KFilename,"filename.ext");
RFile file;
file.Open(theFs,KFilename,EFileWrite|EFileShareAny);

If another instance of RFile tries to open this file in EFileShareExclusive or EFileShareReadersOnly mode, access is denied. However, it can be opened in EFileShareAny mode.

Files may be opened in text or binary mode. Native EPOC applications’ files are nearly all binary, (so they will usually be opened in binary mode). However, they can be opened in text mode (to support testing, and to make them compatible with text formats on remote systems). EPOC native text format uses CR-LF (ASCII 0x0d, 0x0a) to denote the end of a line. When reading, however, any combination of CR, LF, LF-CR or CR-LF is recognised as the end of a line. Where a remote file system uses a different format, it is the responsibility of the installable file system to present an interface for text files which conforms with this format.

The share mode may be OR’ed with either EFileStream or EFileStreamText.

Additionally, it may be OR’ed with either EFileRead or EFileWrite.

EFileShareExclusive

Exclusive access for the program opening the file (=0). No other program can access the file until it is closed. If another program is already accessing the file in any share mode then an attempt to open it with an EFileShareExclusive will fail.

EFileShareReadersOnly

Read-only sharing. This means that the file may only be accessed for reading. A file cannot be opened using a share mode of EFileShareReadersOnly with an EFileWrite flag.

EFileShareAny

Shared access for reading and writing. This means that other programs may share access to the file for reading and writing with the program which opened the file.

EFileStream

For files to be opened in binary mode (=0).

EFileStreamText

For files to be opened in text mode.

EFileRead

The file may be read from but not written to (=0).

EFileWrite

The file may be read from and written to. Cannot be combined with a share mode of EFileShareReadersOnly.