Symbian中如何读入一行文本的类TFileText--SDk

Symbian
Symbian OS Library

SYMBIAN OS V9.2

FEEDBACK 

[Index] [Spacer] [Previous] [Next]



Location: f32file.h
Link against: efsrv.lib

Class TFileText

class TFileText;

Description

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

Members

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


Construction and destruction


TFileText()

IMPORT_C TFileText();

Description

Default constructor.

[Top]


Member functions


Set()

IMPORT_C void Set(RFile &aFile);

Description

Sets the file to be read from, or written to.

This function must be called before Read(), Write() or Seek() can be used.

Parameters
RFile &aFile

The file to be used. Must be open.

See also:
  • TFileText::Read
  • TFileText::Write
  • TFileText::Seek

Read()

IMPORT_C TInt Read(TDes &aDes);

Description

Reads single line text record into the specified descriptor.

The read operation begins at the current file position, and ends when a line delimiter character is read; a record has a maximum length of 256 characters.

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 one of the other system-wide error codes.


Write()

IMPORT_C 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 content to be appended to the file.

Return value
TInt

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

See also:
  • TFileText::Read

Seek()

IMPORT_C TInt Seek(TSeek aMode);

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.

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 one of the other system-wide error codes.

Panic codes
FSCLIENT

5 if aMode is neither ESeekStart nor ESeekEnd.

See also:
  • TFileText::Read
  • TFileText::Write
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值