Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: f32file.h
Link against: efsrv.lib

Class TFileText

TFileText

Support

Supported from 5.0

Description

Reads and writes single lines of text to or from a file.

Defined in TFileText:
Read(), Seek(), Set(), TFileText(), Write()


Construction


TFileText()

TFileText();

Description

The constructor is empty, and is present only to support virtual function table export.

[Top]


Member functions


Set()

void Set(RFile& aFile);

Description

Sets the file to read from or write to. This function must be called before Read(), Write() or Seek() can be used.

Parameters

RFile& aFile

The file to be used by TFileText. Must be open.


Read()

TInt Read(TDes& aDes);

Description

Reads single line text record. The read begins at the current file position and ends when a line delimiter character is read, there is a maximum of 256 characters. The text is read from a file into a descriptor.

If the maximum length of the descriptor is insufficient to hold the record, the function returns KErrTooBig and the descriptor is filled to its maximum length.

If Read() is called when the current position is the end of the file (that is, after the last line delimiter in the file), KErrEof is returned, and the length of the buffer is set to zero.

Parameters

TDes& aDes

On return, contains the single record read from the file. Any previous contents are overwritten.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


Write()

TInt Write(const TDesC& aDes);

Description

Writes the contents of a descriptor to the end of a file. A line delimiter is appended to the descriptor, and the current file position is set to the new end of file.

If the descriptor contains one or more paragraph delimiters, Read() will treat the contents of the descriptor as more than one record.

Parameters

const TDesC& aDes

The descriptor to append to the file

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also:


Seek()

TInt Seek(TSeek aMode) const;

Description

Seeks to start or end of file. It is only necessary to call this function before using Read() because Write() always seeks to the end of the file before writing

Note that aMode must be either ESeekStart or ESeekEnd, otherwise the function raises a FSCLIENT 5 panic.

Parameters

TSeek aMode

ESeekStart to seek to the start of the file; ESeekEnd to seek to the end.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.