[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Objects' (#rtl)

TBufStream

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Buffered file stream

Declaration

Source position: objects.pp line 346

type TBufStream = object(TDosStream)

  LastMode: Byte;

  

Last file open mode

  BufSize: LongInt;

  

Size of buffer

  BufPtr: LongInt;

  

Pointer to current position in buffer

  BufEnd: LongInt;

  

End of data in buffer.

  Buffer: PByteArray;

  

Actual buffer

  constructor Init();

  

Initialize an instance of TBufStream and open the file.

  destructor Done; virtual;

  

Close the file and cleans up the instance.

  procedure Close; virtual;

  

Flush data and Close the file.

  procedure Flush; virtual;

  

FLush data from buffer, and write it to stream.

  procedure Truncate; virtual;

  

Flush buffer, and truncate the file at current position.

  procedure Seek(); virtual;

  

Set current position in file.

  procedure Open(); virtual;

  

Open the file if it is closed.

  procedure Read(); virtual;

  

Read data from the file to a buffer in memory.

  procedure Write(); virtual;

  

Write data to the file from a buffer in memory.

end;

Inheritance

TBufStream

  

Buffered file stream

TDosStream

  

DOS file stream

TStream

  

Base stream class

TObject

  

Basis of all objects

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.


Documentation generated on: Jun 23 2021