BufferedFileStream¶
Qualified name: delphivcl.BufferedFileStream
- class BufferedFileStream¶
Bases:
FileStream
TBufferedFileStream adds buffering support to TFileStream. TBufferedFileStream optimizes multiple consecutive small reads or writes. However, TBufferedFileStream can be used as a drop-in replacement for TFileStream, enabling applications to read from and write to a file on a disk.
Note: TBufferedFileStream will not give performance gain for random position reads or writes, or large reads or writes.
Methods
Writes the buffered data that have not yet been written to the file.
Reads up to Count bytes of data from the resource associated with the handle stream into Buffer.
Read content as bytes.
Read content as float.
Read content as integer.
Read content as string.
Resets the current position of the handle stream.
Writes Count bytes from the Buffer to the current position in the resource.
Write content as bytes.
Write content as float.
Write content as integer.
Write content as string.
Attributes
Capabilities
StreamCapabilities:
Returns the TObject.ClassName
FileName
Preserves the file name of the file associated with the file stream.
Handle
Specifies the handle for the communications resource the stream reads from and writes to.
Position
Indicates the current offset into the stream for reading and writing.
Size
Indicates the size in bytes of the stream.
- ClassName¶
Returns the TObject.ClassName
- FlushBuffer()¶
Writes the buffered data that have not yet been written to the file. When using a buffered file stream, call FlushBuffer to write to the file the data from the buffer that are still not written. Once you call FlushBuffer, the buffer will remain empty until the next read or write operation.
- Read(Buffer, Count: int) int ¶
Reads up to Count bytes of data from the resource associated with the handle stream into Buffer. System.Classes.TBufferedFileStream.Read inherits from System.Classes.THandleStream.Read. All content below this line refers to System.Classes.THandleStream.Read. Reads up to Count bytes of data from the resource associated with the handle stream into Buffer. Use Read to read data from the resource associated with the handle stream when the number of bytes in the file is not known. Read transfers up to Count bytes from the resource, starting at the current position, and then advances the current position in the resource by the number of bytes actually transferred. Read returns the number of bytes actually transferred, which may be less than Count if the end of file marker is encountered. All other data-reading methods of a handle stream (ReadBuffer, ReadComponent) call Read to do the actual reading.
- ReadBytes()¶
Read content as bytes.
- ReadFloat()¶
Read content as float.
- ReadInt()¶
Read content as integer.
- ReadString()¶
Read content as string.
- Seek(Offset: int, Origin: SeekOrigin) int ¶
Resets the current position of the handle stream. System.Classes.TBufferedFileStream.Seek inherits from System.Classes.THandleStream.Seek. All content below this line refers to System.Classes.THandleStream.Seek. Resets the current position of the handle stream. Use Seek to move the current position within the resource associated with the handle stream by the indicated offset. Seek allows an application to read from or write to a particular location within the resource. The Origin parameter indicates how to interpret the Offset parameter. Origin should be one of the following values:
Value
Meaning
soFromBeginning
Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
soFromCurrent
Offset is from the current position in the resource. Seek moves to Position + Offset.
soFromEnd
Offset is from the end of the resource. Offset must be <= 0 to indicate a number of bytes before the end of the file.
Or you can also use TSeekOrigin and its values to indicate where to start a seek operation. Seek returns the new value of the Position property, the new current position in the resource.
- Write(Buffer, Count: int) int ¶
Writes Count bytes from the Buffer to the current position in the resource. System.Classes.TBufferedFileStream.Write inherits from System.Classes.THandleStream.Write. All content below this line refers to System.Classes.THandleStream.Write. Writes Count bytes from the Buffer to the current position in the resource. Use Write to write Count bytes to the resource associated with the handle stream, starting at the current position. After writing to the resource, Write advances the current position by the number bytes written, and returns the number of bytes written. All other data-writing methods of a handle stream (WriteBuffer, WriteComponent) call Write to do the actual writing.
- WriteBytes()¶
Write content as bytes.
- WriteFloat()¶
Write content as float.
- WriteInt()¶
Write content as integer.
- WriteString()¶
Write content as string.