Sign in Join
FPDoc Onlineexperiment

TBufferedFileStream class

In unit BufStream

Implements a buffered file stream with a multi-page buffer.

Declaration

pascal
TBufferedFileStream = class(TFileStream)

Inheritance

  1. TBufferedFileStream
  2. TFileStream
  3. THandleStream
  4. TStream
  5. TObject

Description

TBufferedFileStream is a TFileStream descendant which implements a buffered file stream. It provides a buffer with multiple pages used for random read / write access in the file stream.

By default, It uses a fixed-size buffer consisting of 8 pages with a 4,096 bytes per page. Both page count and page size configurable using the InitializeCache method in the class. The buffer is automatically maintained when the stream size or position is changed, and when reading or writing content to/from the stream.

Pages which have been modified in the buffer are written to the file stream as needed (all pages are used and a read/write operation is performed), when the Flush method is called, and when the class instance is freed. Thus, the class will never use more than the total size obtained by multiplying the CacheBlockSize and aCacheBlockCount arguments to InitializeCache.

This class is suitable when you need to do a lot of random access to a file: hence the use of different pages of configurable size. If you simply wish to speed up sequential reads you better use TReadBufStream or TWriteBufStream for speeding up sequential writes.

See also

Methods

GetPositionprotected
SetPositionprotected
GetSizeprotectedReturn the size of the stream.
SetSize64protected
SetSizeprotected
CreatepublicConstructor for the class instance.
DestroypublicDestructor for the class instance.
SeekpublicMoves the position in the buffer relative to the specified origin.
ReadpublicReads the specified number of bytes into the Buffer parameter.
WritepublicWrites the specified number of bytes in Buffer to the internal page buffer(s).
FlushpublicFlushes modified pages in the buffer to the file stream.
InitializeCachepublicRe-initializes the internal buffer for the buffered file stream.

Inherited

From TFileStream (1)

FileName

From THandleStream (1)

Handle

From TObject (40)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

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