FileBuffer class

Buffered file reader reduces file system disk access by reading in buffers of the file so that individual file reads can be read from the cached buffer.

Constructors

FileBuffer(AbstractFileHandle file, {ByteOrder byteOrder = ByteOrder.littleEndian, int bufferSize = kDefaultBufferSize})
Create a FileBuffer with the given file. byteOrder determines if multi-byte values should be read in bigEndian or littleEndian order. bufferSize controls the size of the buffer to use for file IO caching. The larger the buffer, the less it will have to access the file system.
FileBuffer.from(FileBuffer other, {int? bufferSize})

Properties

buffer Uint8List
Get the file buffer, reloading it as necessary
no setter
byteOrder ByteOrder
final
file AbstractFileHandle
final
hashCode int
The hash code for this object.
no setterinherited
isOpen bool
True if the file is currently open.
no setter
length int
The length of the file in bytes.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
Close the file asynchronously.
closeSync() → void
Close the file synchronously.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() bool
Open the file synchronously for reading.
readBytes(int position, int count, [int? fileSize]) Uint8List
Read count bytes starting at the given position within the file.
readUint16(int position, [int? fileSize]) int
Read a 16-bit unsigned int at the given position within the file.
readUint24(int position, [int? fileSize]) int
Read a 24-bit unsigned int at the given position within the file.
readUint32(int position, [int? fileSize]) int
Read a 32-bit unsigned int at the given position within the file.
readUint64(int position, [int? fileSize]) int
Read a 64-bit unsigned int at the given position within the file.
readUint8(int position, [int? fileSize]) int
Read an 8-bit unsigned int at the given position within the file. fileSize is used to ensure bytes aren't read past the end of an InputFileStream.
reset() → void
Reset the read position of the file back to 0.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kDefaultBufferSize → const int
kMinBufferSize → const int
The buffer size should be at least 8 bytes, so reading a 64-bit value doesn't have to deal with buffer overflow.