BinaryReader
Streaming binary reader returned by utils.OpenBinaryReader.
Streaming binary reader returned by utils.OpenBinaryReader.
Closed: boolean = false
Indicates whether the reader has been closed.
EOF: boolean = false
Indicates that the current read position has reached the file length recorded when the reader was opened.
This property does not report a closed reader or a read failure. Use the return value of Read to drive the read loop; EOF is status information used to distinguish a clean end of file from a failed read.
Length: number = 0
File size in bytes as observed when the reader was opened.
Position: number = 0
Number of bytes successfully read from the file.
Close()
Closes the file. Calling Close() more than once is allowed.
boolean — true if the reader is closed successfully; false if closing the file fails. Calling it again after a successful close returns true.
Read(buffer, offset, count)
Reads bytes into an existing Uint8Array without allocating a new buffer.
If offset is omitted, reading starts at index 0. If count is omitted, bytes are read up to the end of the buffer.
An explicitly supplied offset + count must fit inside the buffer.
| Name | Type | Description |
|---|---|---|
buffer | Uint8Array | Destination buffer. |
offset = 0optional | number | Destination offset in bytes. |
countoptional | number | Maximum number of bytes to read. Defaults to the remaining buffer size. |
number — Number of bytes actually read. A nonzero request returning 0 means that no bytes were read: EOF is true at clean end of file and false if the read could not be performed. A zero-length request also returns 0.
Error — If the reader is closed.