TBufStream
[Properties (by Name)][Methods (by Name)][Events (by Name)]
Buffered file stream
Declaration
Source position: objects.pp line 372
Type
TBufStream = object (TDosStream)
LastMode : Byte;
BufSize : LongInt;
BufPtr : LongInt;
BufEnd : LongInt;
Buffer : PByteArray;
constructor Init(FileName: FNameStr; Mode: Word; Size: Word);
destructor Done; Virtual;
procedure Close; Virtual;
procedure Flush; Virtual;
procedure Truncate; Virtual;
procedure Seek(Pos: LongInt); Virtual;
procedure Open(OpenMode: Word); Virtual;
procedure Read(var Buf; Count: LongInt); Virtual;
procedure Write(var Buf; Count: LongInt); Virtual;
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.
Members
Member | Type | Visibility | Description |
---|---|---|---|
BufEnd | Field | default | End of data in buffer. |
Buffer | Field | default | Actual buffer |
BufPtr | Field | default | Pointer to current position in buffer |
BufSize | Field | default | Size of buffer |
Close | Method | default | Flush data and Close the file. |
Done | Method | default | Close the file and cleans up the instance. |
Flush | Method | default | FLush data from buffer, and write it to stream. |
Init | Method | default | Initialize an instance of TBufStream and open the file. |
LastMode | Field | default | Last file open mode |
Open | Method | default | Open the file if it is closed. |
Read | Method | default | Read data from the file to a buffer in memory. |
Seek | Method | default | Set current position in file. |
Truncate | Method | default | Flush buffer, and truncate the file at current position. |
Write | Method | default | Write data to the file from a buffer in memory. |
Inheritance
Class | Description |
---|---|
TBufStream | Buffered file stream |
See also
Name | Description |
---|---|
Byte | An unsigned 8-bits integer |
LongInt | A signed 32-bits integer |
LongInt | A signed 32-bits integer |
LongInt | A signed 32-bits integer |
TByteArray | Array with maximum allowed number of bytes. |