Skip to content

TBufferedFileStream.Read

Reads the specified number of bytes into the Buffer parameter.

Declaration

Source position: bufstream.pp line 139

public 
function TBufferedFileStream.Read(var Buffer; Count: LongInt) : LongInt
                                 ;  override;

Description

Read is used to read the specified number of bytes in Count, and store the values in the Buffer parameter. Read is overridden to use the internal buffer for the operation instead directly accessing of the underlying file stream. It locates the page in the buffer with the content for the stream position.

Read maintains the pages in the buffer as needed for the request. This includes writing and recycling older buffer pages, locating the position in the file stream for a new buffer page, and loading the content for a buffer page from the file stream.

Buffer is updated with the values copied from the internal buffer. The return value contains the actual number of bytes read from the internal buffer, or 0 when no content is available in the buffer at the current stream position.

Use Seek or Position to set the stream position (when needed) prior to calling Read.

Errors

Read raises an EStreamError exception with the message in SErrCacheUnexpectedPageDiscard when a page has been unexpectedly discarded in the buffer.