RFileBuf Class Reference

class RFileBuf : public TStreamBuf

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.

Open(), Close(), Attach(), Detach(), File() and Reattach() usage patterns:

Pattern 1: RFileBuf owns the file step 1a: Open()/Create()/Temp() is used to connect the buffer to a file step 1b: Use the file buffer step 1c: Close() releases this resource.

Pattern 2: RFile is opened elsewhere and ownership is handed over to RFileBuf This may happen if the file is already opened by another API, or from another process for example step 2a: Attach() is used to hand ownership of the opened file to the buffer. After Attach() the supplied file handle is NULLed. step 2b: Use the file buffer step 2c: Close() releases the file resource.

Pattern 3: RFileBuf is used transiently to manage an existing opened file: step 3a: Attach() is used to bind the buffer to the already open file. After Attach() the supplied file handle is NULLed. step 3b: Use the file buffer step 3c: RFileBuf::File() is used to retrieve the file handle again, then Detach() is called to disconnect the buffer from the file. At this point, the destruction of the file buffer will have no effect on the file. The retrieved file handle in step 3c must be used to close the file.

Pattern 4: Transient direct file access to a buffered file step 4a: RFileBuf::File() is used to retrieve the file handle. [Optional: Detach() is used to disconnect the file buffer] step 4b: Use the file directly. Note that writing to the file may cause coherency problems with the RFileBuf buffer - in which case you need to Reset() the buffer as well. step 4c: [Optional: Reattach() is used to hand the file back to the buffer]. Use of the buffer is resumed

CFileStore

RFileReadStream

RFileWriteStream

Inherits from

Public Member Functions
RFileBuf()
RFileBuf(TInt)
RFileBuf(TCapture< RFileBuf >)
IMPORT_C voidAttach(RFile &, TInt)
IMPORT_C voidClose()
IMPORT_C TIntCreate(RFs &, const TDesC &, TUint)
voidDetach()
RFile &File()
IMPORT_C TIntOpen(RFs &, const TDesC &, TUint)
voidReattach(RFile &)
IMPORT_C TIntReplace(RFs &, const TDesC &, TUint)
IMPORT_C voidReset()
voidReset(TInt)
IMPORT_C voidSetSizeL(TInt)
IMPORT_C TIntTemp(RFs &, const TDesC &, TFileName &, TUint)
Protected Member Functions
IMPORT_C TIntDoReadL(TAny *, TInt)
IMPORT_C TIntDoReadL(TDes8 &, TInt, TRequestStatus &)
IMPORT_C voidDoRelease()
IMPORT_C TStreamPosDoSeekL(TMark, TStreamLocation, TInt)
IMPORT_C voidDoSynchL()
IMPORT_C voidDoWriteL(const TAny *, TInt)
IMPORT_C TIntDoWriteL(const TDesC8 &, TInt, TRequestStatus &)
IMPORT_C voidOverflowL()
voidSetBuf(TRead, TUint8 *, TUint8 *)
voidSetBuf(TWrite, TUint8 *, TUint8 *)
voidSetBuf(TArea, TUint8 *, TUint8 *)
IMPORT_C TIntUnderflowL(TInt)
Private Member Functions
TUint8 *AllocL()
TInt EndL()
TInt FileReadL(TAny *, TInt)
voidFileWriteL(const TAny *, TInt, TInt)
voidFileWriteL(const TAny *, TInt)
voidFree()
TInt Lag(TRead)
TInt Lag(TWrite)
TUint8 *Limit(TWrite)
TInt Mark(TMark)
TInt Mark(TRead)
TInt Mark(TWrite)
TInt MovePos(TRead, TInt)
TInt MovePos(TWrite, TInt)
TInt Pos(TRead)
TInt Pos(TWrite)
TInt Reach(TWrite)
voidSetLimit(TWrite, TUint8 *)
voidSetPos(TMark, TInt)
voidSetPos(TRead, TInt)
voidSetPos(TWrite, TInt)
TInt Span(TWrite)
Inherited Functions
MStreamBuf::MStreamBuf()
MStreamBuf::PushL()
MStreamBuf::Read(TDes8 &,TInt,TRequestStatus &)
MStreamBuf::Read(TDes8 &,TRequestStatus &)
MStreamBuf::ReadL(MStreamInput &)
MStreamBuf::ReadL(MStreamInput &,TInt)
MStreamBuf::ReadL(MStreamInput &,TStreamTransfer)
MStreamBuf::ReadL(TAny *,TInt)
MStreamBuf::ReadL(TDes8 &,TInt,TRequestStatus &)
MStreamBuf::ReadL(TDes8 &,TRequestStatus &)
MStreamBuf::Release()
MStreamBuf::SeekL(TMark,TStreamLocation,TInt)
MStreamBuf::SeekL(TMark,TStreamPos)
MStreamBuf::SeekL(TRead,TInt)
MStreamBuf::SeekL(TRead,TStreamLocation,TInt)
MStreamBuf::SeekL(TWrite,TInt)
MStreamBuf::SeekL(TWrite,TStreamLocation,TInt)
MStreamBuf::SizeL()const
MStreamBuf::Synch()
MStreamBuf::SynchL()
MStreamBuf::TellL(TRead)const
MStreamBuf::TellL(TWrite)const
MStreamBuf::Write(const TDesC8 &,TInt,TRequestStatus &)
MStreamBuf::Write(const TDesC8 &,TRequestStatus &)
MStreamBuf::WriteL(MStreamOutput &)
MStreamBuf::WriteL(MStreamOutput &,TInt)
MStreamBuf::WriteL(MStreamOutput &,TStreamTransfer)
MStreamBuf::WriteL(const TAny *,TInt)
MStreamBuf::WriteL(const TDesC8 &,TInt,TRequestStatus &)
MStreamBuf::WriteL(const TDesC8 &,TRequestStatus &)
TStreamBuf::Avail(TArea)const
TStreamBuf::Avail(TRead)const
TStreamBuf::Avail(TWrite)const
TStreamBuf::DoReadL(MStreamInput &,TStreamTransfer)
TStreamBuf::DoWriteL(MStreamOutput &,TStreamTransfer)
TStreamBuf::End(TArea)const
TStreamBuf::End(TRead)const
TStreamBuf::End(TWrite)const
TStreamBuf::Ptr(TArea)const
TStreamBuf::Ptr(TRead)const
TStreamBuf::Ptr(TWrite)const
TStreamBuf::SetEnd(TArea,TUint8 *)
TStreamBuf::SetEnd(TRead,TUint8 *)
TStreamBuf::SetEnd(TWrite,TUint8 *)
TStreamBuf::SetPtr(TArea,TUint8 *)
TStreamBuf::SetPtr(TRead,TUint8 *)
TStreamBuf::SetPtr(TWrite,TUint8 *)
TStreamBuf::TStreamBuf()
Inherited Enumerations
MStreamBuf:TRead
MStreamBuf:TWrite
Private Attributes
TUint8 *iBase
TInt iExt
__MUTABLE RFileiFile
TInt iRPos
TInt iSize
TUint8 *iWLim
TInt iWPos

Constructor & Destructor Documentation

RFileBuf()

IMPORT_CRFileBuf()

RFileBuf(TInt)

IMPORT_CRFileBuf(TIntaSize)

Parameters

TInt aSize

RFileBuf(TCapture< RFileBuf >)

RFileBuf(TCapture< RFileBuf >aCapture)

Parameters

TCapture< RFileBuf > aCapture

Member Functions Documentation

AllocL()

TUint8 *AllocL()[private]

Attach(RFile &, TInt)

IMPORT_C voidAttach(RFile &aFile,
TIntaPos = 0
)

Parameters

RFile & aFile
TInt aPos = 0

Close()

IMPORT_C voidClose()

Create(RFs &, const TDesC &, TUint)

IMPORT_C TIntCreate(RFs &aFs,
const TDesC &aName,
TUintaFileMode
)

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode

Detach()

voidDetach()[inline]

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.

Attach()

Reattach()

DoReadL(TAny *, TInt)

IMPORT_C TIntDoReadL(TAny *aPtr,
TIntaMaxLength
)[protected, virtual]

Parameters

TAny * aPtr
TInt aMaxLength

DoReadL(TDes8 &, TInt, TRequestStatus &)

IMPORT_C TIntDoReadL(TDes8 &aDes,
TIntaMaxLength,
TRequestStatus &aStatus
)[protected, virtual]

Parameters

TDes8 & aDes
TInt aMaxLength
TRequestStatus & aStatus

DoRelease()

IMPORT_C voidDoRelease()[protected, virtual]

DoSeekL(TMark, TStreamLocation, TInt)

IMPORT_C TStreamPosDoSeekL(TMarkaMark,
TStreamLocationaLocation,
TIntanOffset
)[protected, virtual]

Parameters

TMark aMark
TStreamLocation aLocation
TInt anOffset

DoSynchL()

IMPORT_C voidDoSynchL()[protected, virtual]

DoWriteL(const TAny *, TInt)

IMPORT_C voidDoWriteL(const TAny *aPtr,
TIntaLength
)[protected, virtual]

Parameters

const TAny * aPtr
TInt aLength

DoWriteL(const TDesC8 &, TInt, TRequestStatus &)

IMPORT_C TIntDoWriteL(const TDesC8 &aDes,
TIntaMaxLength,
TRequestStatus &aStatus
)[protected, virtual]

Parameters

const TDesC8 & aDes
TInt aMaxLength
TRequestStatus & aStatus

EndL()

TInt EndL()[private]

File()

RFile &File()const [inline]

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

The file attached to this stream buffer.

FileReadL(TAny *, TInt)

TInt FileReadL(TAny *aPtr,
TIntaMaxLength
)[private]

Parameters

TAny * aPtr
TInt aMaxLength

FileWriteL(const TAny *, TInt, TInt)

voidFileWriteL(const TAny *aPtr,
TIntaLength,
TIntaSeek
)[private]

Parameters

const TAny * aPtr
TInt aLength
TInt aSeek

FileWriteL(const TAny *, TInt)

voidFileWriteL(const TAny *aPtr,
TIntaLength
)[private]

Parameters

const TAny * aPtr
TInt aLength

Free()

voidFree()[private]

Lag(TRead)

TInt Lag(TRead)const [private, inline]

Parameters

TRead

Lag(TWrite)

TInt Lag(TWrite)const [private, inline]

Parameters

TWrite

Limit(TWrite)

TUint8 *Limit(TWrite)const [private, inline]

Parameters

TWrite

Mark(TMark)

TInt Mark(TMarkaMark)const [private]

Parameters

TMark aMark

Mark(TRead)

TInt Mark(TRead)const [private, inline]

Parameters

TRead

Mark(TWrite)

TInt Mark(TWrite)const [private, inline]

Parameters

TWrite

MovePos(TRead, TInt)

TInt MovePos(TRead,
TIntanOffset
)[private, inline]

Parameters

TRead
TInt anOffset

MovePos(TWrite, TInt)

TInt MovePos(TWrite,
TIntanOffset
)[private, inline]

Parameters

TWrite
TInt anOffset

Open(RFs &, const TDesC &, TUint)

IMPORT_C TIntOpen(RFs &aFs,
const TDesC &aName,
TUintaFileMode
)

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode

OverflowL()

IMPORT_C voidOverflowL()[protected, virtual]

Empties the intermediate buffer and resets the start and end points of the write area.

The implementation of this function depends on the way the stream itself is implemented. For example, the in-memory streams have simple implementations.

Pos(TRead)

TInt Pos(TRead)const [private, inline]

Parameters

TRead

Pos(TWrite)

TInt Pos(TWrite)const [private, inline]

Parameters

TWrite

Reach(TWrite)

TInt Reach(TWrite)const [private, inline]

Parameters

TWrite

Reattach(RFile &)

voidReattach(RFile &aFile)[inline]

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.

Attach()

Detach()

Parameters

RFile & aFileThe file to be re-attached.

Replace(RFs &, const TDesC &, TUint)

IMPORT_C TIntReplace(RFs &aFs,
const TDesC &aName,
TUintaFileMode
)

Parameters

RFs & aFs
const TDesC & aName
TUint aFileMode

Reset()

IMPORT_C voidReset()

Reset(TInt)

voidReset(TIntaSize)[inline]

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

The intermediate buffer must not contain any outstanding write data, otherwise the function raises a STORE-File 6 panic.

Parameters

TInt aSizeThe size of any future intermediate buffer.

SetBuf(TRead, TUint8 *, TUint8 *)

voidSetBuf(TRead,
TUint8 *aPtr,
TUint8 *anEnd
)[protected, inline]

Sets the start and end points of the read area within the intermediate buffer.

A start point is always within an area; an end point is always the first byte beyond the end of an area.

MStreamBuf::TRead

Parameters

TRead
TUint8 * aPtrThe start point.
TUint8 * anEndThe end point.

SetBuf(TWrite, TUint8 *, TUint8 *)

voidSetBuf(TWrite,
TUint8 *aPtr,
TUint8 *anEnd
)[protected, inline]

Sets the start and end points of the write area within the intermediate buffer.

A start point is always within an area; an end point is always the first byte beyond the end of an area.

MStreamBuf::TWrite

Parameters

TWrite
TUint8 * aPtrThe start point.
TUint8 * anEndThe end point.

SetBuf(TArea, TUint8 *, TUint8 *)

voidSetBuf(TAreaanArea,
TUint8 *aPtr,
TUint8 *anEnd
)[protected, inline]

Parameters

TArea anArea
TUint8 * aPtr
TUint8 * anEnd

SetLimit(TWrite, TUint8 *)

voidSetLimit(TWrite,
TUint8 *aLimit
)[private, inline]

Parameters

TWrite
TUint8 * aLimit

SetPos(TMark, TInt)

voidSetPos(TMarkaMark,
TIntaPos
)[private]

Parameters

TMark aMark
TInt aPos

SetPos(TRead, TInt)

voidSetPos(TRead,
TIntaPos
)[private, inline]

Parameters

TRead
TInt aPos

SetPos(TWrite, TInt)

voidSetPos(TWrite,
TIntaPos
)[private, inline]

Parameters

TWrite
TInt aPos

SetSizeL(TInt)

IMPORT_C voidSetSizeL(TIntaSize)

Parameters

TInt aSize

Span(TWrite)

TInt Span(TWrite)const [private, inline]

Parameters

TWrite

Temp(RFs &, const TDesC &, TFileName &, TUint)

IMPORT_C TIntTemp(RFs &aFs,
const TDesC &aPath,
TFileName &aName,
TUintaFileMode
)

Parameters

RFs & aFs
const TDesC & aPath
TFileName & aName
TUint aFileMode

UnderflowL(TInt)

IMPORT_C TIntUnderflowL(TIntaMaxLength)[protected, virtual]

Re-fills the intermediate buffer and resets the start and end points of the read area.

The implementation of this function depends on the way the stream itself is implemented. For example, the in-memory streams have simple implementations.

The amount of data available in the intermediate buffer.

Parameters

TInt aMaxLengthThe maximum amount of data required for the intermediate buffer.

Member Data Documentation

TUint8 * iBase

TUint8 *iBase[private]

TInt iExt

TInt iExt[private]

__MUTABLE RFile iFile

__MUTABLE RFileiFile[private]

TInt iRPos

TInt iRPos[private]

TInt iSize

TInt iSize[private]

TUint8 * iWLim

TUint8 *iWLim[private]

TInt iWPos

TInt iWPos[private]