[Overview][Constants][Classes][Index] | Reference for unit 'bufstream' (#fcl)

# TBufferedFileStream.Read

Reads the specified number of bytes into the Buffer parameter

## Declaration

Source position: bufstream.pp line 132

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

## Arguments

`Buffer` |  | Buffer where the values read in the method are stored
`Count` |  | Number of bytes requested for the read operation

## Function result

Number of bytes actually read in the method

## 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.

## See also

THandleStream.Read
THandleStream.Seek
TStream.Read
TStream.Seek
TStream.Position
EStreamError

Documentation generated on: May 14 2021