Sign in Join
FPDoc Onlineexperiment

TBufferedFileStream.Write function

Member of TBufferedFileStreampublicIn unit BufStream

Writes the specified number of bytes in Buffer to the internal page buffer(s).

Declaration

pascal
function Write(const Buffer; Count: LongInt): LongInt; override

Arguments

Buffer

Buffer with the values written in the method.

Count

Number of bytes requested in the write operation.

Function result

Actual number of bytes written in the method.

Description

Write is a LongInt function used to write byte values in Buffer to the current position in the buffered file stream. Count contains the number of bytes requested in the write operation.

Write is overridden to use the internal buffer in the operation instead of the underlying file stream. It locates the page in the buffer with the content for the buffered stream position.

Write maintains the pages in the buffer as needed for the request. This includes recycling older buffer pages, reading values from the stream for a new buffer page, and storing the new content in the internal buffer.

Buffer contains the values stored in the internal buffer in the request. The return value contains the actual number of bytes written, or 0 if the write could not be performed.

Use Seek or Position to set the buffer position (when needed) prior to calling Write.

Errors

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

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.