Skip to content

TBufStream

Buffered file stream.

Declaration

Source position: objects.pp line 386

type

  TBufStream = object(TDosStream)
    LastMode: Byte;
    BufSize: LongInt;
    BufPtr: LongInt;
    BufEnd: LongInt;
    Buffer: PByteArray = ^TByteArray;
    constructor Init;
    destructor Done;
    procedure Close;
    procedure Flush;
    procedure Truncate;
    procedure Seek;
    procedure Open;
    procedure Read;
    procedure Write;
  end;

Description

Bufstream implements a buffered file stream. That is, all data written to the stream is written to memory first. Only when the buffer is full, or on explicit request, the data is written to disk.

Also, when reading from the stream, first the buffer is checked if there is any unread data in it. If so, this is read first. If not the buffer is filled again, and then the data is read from the buffer.

The size of the buffer is fixed and is set when constructing the file.

This is useful if you need heavy throughput for your stream, because it speeds up operations.

Methods

Member Visibility Description
Close default Flush data and Close the file.
Done default Close the file and cleans up the instance.
Flush default FLush data from buffer, and write it to stream.
Init default Initialize an instance of TBufStream and open the file.
Open default Open the file if it is closed.
Read default Read data from the file to a buffer in memory.
Seek default Set current position in file.
Truncate default Flush buffer, and truncate the file at current position.
Write default Write data to the file from a buffer in memory.
See all Methods

Fieldss

Member Visibility Description
BufEnd default End of data in buffer.
Buffer default Actual buffer.
BufPtr default Pointer to current position in buffer.
BufSize default Size of buffer.
LastMode default Last file open mode.
See all Fieldss