Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: s32file.h
Link against: estor.lib

Class RFileBuf

RFileBuf

Support

Supported from 5.0

Description

A stream buffer hosted by a file.

Instances of this class are used by file based persistent stores, i.e. CFileStore type objects. An RFileBuf object is associated with a file and the file is said to be attached to the stream buffer.

An RFileBuf object is also used by RFileReadStream and RFileWriteStream objects to provide buffered file I/O.

The stream buffer has intermediate buffering capabilities.

When used as the basis for a file store, it hosts multiple streams through the TStreamExchange and RShareBuf classes

Derivation

MStreamBufA stream buffer that provides a generic I/O interface for streamed data
RFileBufA stream buffer hosted by a file
TStreamBufAdds buffering capabilities to a stream buffer

Defined in RFileBuf:
Reset(), Attach(), Close(), Create(), Detach(), File(), Open(), RFileBuf(), Reattach(), Replace(), Reset(), SetSizeL(), Temp()

Inherited from MStreamBuf:
SeekL(), DoRelease(), DoSeekL(), DoSynchL(), ERead, EWrite, PushL(), Read(), ReadL(), Release(), SeekL(), SizeL(), Synch(), SynchL(), TMark, TRead, TWrite, TellL(), Write(), WriteL()

Inherited from TStreamBuf:
Avail(), DoReadL(), DoWriteL(), End(), OverflowL(), Ptr(), SetBuf(), SetEnd(), SetPtr(), TArea, UnderflowL()

See also:


Construction


RFileBuf()

RFileBuf();

Description

Constructs the object with a default intermediate buffer size.

The size of the intermediate buffer is the value of the constant KDefaultFileBufSize.


RFileBuf()

RFileBuf(TInt aSize);

Description

Constructs the object with the specified intermediate buffer size.

Parameters

TInt aSize

The size of the intermediate buffer.

Notes:

[Top]


Member functions


Reset()

void Reset();

Description

Frees the intermediate buffer.

If there is any read data in the intermediate buffer, then the function reverts the read position within the stream.

Notes:


Reset()

void Reset(TInt aSize);

Description

Frees the intermediate buffer and changes the size of any future intermediate buffer to the specified value.

Parameters

TInt aSize

The size of any future intermediate buffer.

Notes:


SetSizeL()

void SetSizeL(TInt aSize);
    

Description

Changes the size of the file attached to this buffer to the specified value.

Writes any outstanding data from the intermediate buffer to the stream hosted by the file. Any data in the intermediate buffer that would lie beyond the end of the truncated file, is not written.

Parameters

TInt aSize

The new size of the file.


Attach()

void Attach(RFile& aFile,TInt aPos=0);

Description

Attaches the specified file to this stream buffer.

The function also re-sets the intermediate buffer's read and write marks to the beginning of the intermediate buffer and sets the read and write stream positions to the specified offset within the file.

Parameters

RFile& aFile

The file to be attached.

TInt aPos

The offset within the file to which the read and write stream positions are set. By default this is zero.

See also:


Detach()

void Detach();

Description

Detaches the file from this stream buffer.

The intermediate buffer's read and write marks are not changed, and the stream positions are not changed. This means that the contents of the file should not change while it is detached.

See also:


Reattach()

void Reattach(RFile& aFile);

Description

Re-attaches the specified file to this stream buffer.

The intermediate buffer's read and write marks are not changed, and the stream positions are not changed.

The file should be the one that was detached using the Detach() function.

Parameters

RFile& aFile

The file to be re-attached.

See also:


Open()

TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode);

Description

Opens the specified file and attaches it to this stream buffer.

Parameters

RFs& aFs

Handle to a file server session through which the file is opened.

const TDesC& aName

The name of the file to be opened.

TUint aFileMode

The mode in which the file is to be accessed. The mode is defined by the TFileMode type.

Return value

TInt

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

Notes:

See also:


Create()

TInt Create(RFs& aFs,const TDesC& aName,TUint aFileMode);

Description

Creates a file with the specified name and attaches it to this stream buffer.

The file must not already exist.

Parameters

RFs& aFs

Handle to a file server session through which the file is created.

const TDesC& aName

The name of the file to be created.

TUint aFileMode

The mode in which the file is to be accessed. The mode is defined by the TFileMode type.

Return value

TInt

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

Notes:

See also:


Replace()

TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode);

Description

Replaces the file with the specified name and attaches it to this stream buffer.

If there is an existing file with the same name, then this function overwrites it. If the file does not already exist, it is created.

Parameters

RFs& aFs

Handle to a file server session through which the file is replaced.

const TDesC& aName

The name of the file to be replaced.

TUint aFileMode

The mode in which the file is to be accessed. The mode is defined by the TFileMode type.

Return value

TInt

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

Notes:

See also:


Temp()

TInt Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode);

Description

Creates and opens a temporary file with a unique name and attaches it to this stream buffer.

Parameters

RFs& aFs

Handle to a file server session through which the file is created.

const TDesC& aPath

The directory in which the file is created.

const TDesC& aName

On return, contains the full path and file name of the file. The filename is guaranteed to be unique within the specified directory.

TUint aFileMode

The mode in which the file is to be accessed. The mode is defined by the TFileMode type.

See also:


File()

RFile& File() const;

Description

Gets a reference to the file attached to this stream buffer.

Return value

RFile&

The file attached to this stream buffer.


Close()

void Close();

Description

Writes any outstanding data from the intermediate buffer before freeing the intermediate buffer and closing the attached file.

[Top]


Internal members


RFileBuf()

RFileBuf(TCapture<RFileBuf> aCapture);

Description

This is internal and is not intended for use.

Parameters

TCapture<RFileBuf> aCapture

No description.