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
Public Member Functions | |
---|---|
RFileBuf() | |
RFileBuf(TInt) | |
RFileBuf(TCapture< RFileBuf >) | |
IMPORT_C void | Attach(RFile &, TInt) |
IMPORT_C void | Close() |
IMPORT_C TInt | Create(RFs &, const TDesC &, TUint) |
void | Detach() |
RFile & | File() |
IMPORT_C TInt | Open(RFs &, const TDesC &, TUint) |
void | Reattach(RFile &) |
IMPORT_C TInt | Replace(RFs &, const TDesC &, TUint) |
IMPORT_C void | Reset() |
void | Reset(TInt) |
IMPORT_C void | SetSizeL(TInt) |
IMPORT_C TInt | Temp(RFs &, const TDesC &, TFileName &, TUint) |
Protected Member Functions | |
---|---|
IMPORT_C TInt | DoReadL(TAny *, TInt) |
IMPORT_C TInt | DoReadL(TDes8 &, TInt, TRequestStatus &) |
IMPORT_C void | DoRelease() |
IMPORT_C TStreamPos | DoSeekL(TMark, TStreamLocation, TInt) |
IMPORT_C void | DoSynchL() |
IMPORT_C void | DoWriteL(const TAny *, TInt) |
IMPORT_C TInt | DoWriteL(const TDesC8 &, TInt, TRequestStatus &) |
IMPORT_C void | OverflowL() |
void | SetBuf(TRead, TUint8 *, TUint8 *) |
void | SetBuf(TWrite, TUint8 *, TUint8 *) |
void | SetBuf(TArea, TUint8 *, TUint8 *) |
IMPORT_C TInt | UnderflowL(TInt) |
Private Member Functions | |
---|---|
TUint8 * | AllocL() |
TInt | EndL() |
TInt | FileReadL(TAny *, TInt) |
void | FileWriteL(const TAny *, TInt, TInt) |
void | FileWriteL(const TAny *, TInt) |
void | Free() |
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) |
void | SetLimit(TWrite, TUint8 *) |
void | SetPos(TMark, TInt) |
void | SetPos(TRead, TInt) |
void | SetPos(TWrite, TInt) |
TInt | Span(TWrite) |
Inherited Enumerations | |
---|---|
MStreamBuf:TRead | |
MStreamBuf:TWrite |
Private Attributes | |
---|---|
TUint8 * | iBase |
TInt | iExt |
__MUTABLE RFile | iFile |
TInt | iRPos |
TInt | iSize |
TUint8 * | iWLim |
TInt | iWPos |
RFileBuf | ( | TCapture< RFileBuf > | aCapture | ) |
TCapture< RFileBuf > aCapture |
IMPORT_C TInt | Create | ( | RFs & | aFs, |
const TDesC & | aName, | |||
TUint | aFileMode | |||
) |
void | Detach | ( | ) | [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.
IMPORT_C TInt | DoReadL | ( | TDes8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [protected, virtual] |
TDes8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
IMPORT_C TStreamPos | DoSeekL | ( | TMark | aMark, |
TStreamLocation | aLocation, | |||
TInt | anOffset | |||
) | [protected, virtual] |
TMark aMark | |
TStreamLocation aLocation | |
TInt anOffset |
IMPORT_C void | DoWriteL | ( | const TAny * | aPtr, |
TInt | aLength | |||
) | [protected, virtual] |
IMPORT_C TInt | DoWriteL | ( | const TDesC8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [protected, virtual] |
const TDesC8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
RFile & | File | ( | ) | const [inline] |
Gets a reference to the file attached to this stream buffer.
The file attached to this stream buffer.
void | FileWriteL | ( | const TAny * | aPtr, |
TInt | aLength, | |||
TInt | aSeek | |||
) | [private] |
IMPORT_C void | OverflowL | ( | ) | [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.
void | Reattach | ( | RFile & | aFile | ) | [inline] |
RFile & aFile | The file to be re-attached. |
IMPORT_C TInt | Replace | ( | RFs & | aFs, |
const TDesC & | aName, | |||
TUint | aFileMode | |||
) |
void | Reset | ( | TInt | aSize | ) | [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.
TInt aSize | The size of any future intermediate buffer. |
void | SetBuf | ( | 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.
void | SetBuf | ( | 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.
void | SetBuf | ( | TArea | anArea, |
TUint8 * | aPtr, | |||
TUint8 * | anEnd | |||
) | [protected, inline] |
IMPORT_C TInt | Temp | ( | RFs & | aFs, |
const TDesC & | aPath, | |||
TFileName & | aName, | |||
TUint | aFileMode | |||
) |
IMPORT_C TInt | UnderflowL | ( | TInt | aMaxLength | ) | [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.
TInt aMaxLength | The maximum amount of data required for the intermediate buffer. |