TBufferedFileStream class
Implements a buffered file stream with a multi-page buffer.
Declaration
TBufferedFileStream = class(TFileStream)Inheritance
- TBufferedFileStream
- TFileStream
- THandleStream
- TStream
- 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
GetPosition | protected | |
SetPosition | protected | |
GetSize | protected | Return the size of the stream. |
SetSize64 | protected | |
SetSize | protected | |
Create | public | Constructor for the class instance. |
Destroy | public | Destructor for the class instance. |
Seek | public | Moves the position in the buffer relative to the specified origin. |
Read | public | Reads the specified number of bytes into the Buffer parameter. |
Write | public | Writes the specified number of bytes in Buffer to the internal page buffer(s). |
Flush | public | Flushes modified pages in the buffer to the file stream. |
InitializeCache | public | Re-initializes the internal buffer for the buffered file stream. |
Inherited
From TFileStream (1)
From THandleStream (1)
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.
