wavelength 1.0.0
Loading...
Searching...
No Matches
LazyFileStream Class Reference

Double-buffered reader with one asynchronous read of a file always in flight. More...

#include <lazyfilestream.h>

Public Member Functions

 LazyFileStream (const String &filename, int nBufferSize)
 Open a file, allocate the buffers, and start the first read.
 ~LazyFileStream ()
 Close the file and free the buffers.
bool Eof () const
 Report whether the last read reached the end of the file.
bool ReadDone ()
 Report whether the read in flight is complete, recording how many bytes arrived.
char * GetData (int *pnPosition, int *pnBytesAvailable)
 Take the buffer of the completed read, and start the next read unless the file ended.
 LazyFileStream (const String &filename, int bufferSize)
 Open a file, allocate the buffers, and start the first read.
 ~LazyFileStream ()
 Close the file and free the buffers.
bool Eof () const
 Report whether the last read reached the end of the file.
bool ReadDone ()
 Report whether the read in flight is complete, recording how many bytes arrived.
char * GetData (int *position, int *bytesAvailable)
 Take the buffer of the completed read, and start the next read unless the file ended.

Detailed Description

Double-buffered reader with one asynchronous read of a file always in flight.

The class has no RTTI, and its name comes from the allocation tag of its buffers. The object is 0x20 bytes. While the caller consumes one buffer, the next read fills the other.

The class has no RTTI, and its name comes from its source file. The object is 0x20 bytes. While the caller consumes one buffer, the next read fills the other.

Constructor & Destructor Documentation

◆ LazyFileStream() [1/2]

LazyFileStream::LazyFileStream ( const String & filename,
int nBufferSize )

Open a file, allocate the buffers, and start the first read.

Parameters
filenameThe path of the file.
nBufferSizeThe size of each buffer in bytes.
Ghidra address:
NTSC-U/C: 0x002517f0
Ghidra address:
PAL: 0x0025a198

◆ ~LazyFileStream() [1/2]

LazyFileStream::~LazyFileStream ( )

Close the file and free the buffers.

Ghidra address:
NTSC-U/C: 0x002518a8
Ghidra address:
PAL: 0x0025a250

◆ LazyFileStream() [2/2]

LazyFileStream::LazyFileStream ( const String & filename,
int bufferSize )

Open a file, allocate the buffers, and start the first read.

Parameters
filenameThe path of the file.
bufferSizeThe size of each buffer in bytes.
Ghidra address:
0x1002ccf0

◆ ~LazyFileStream() [2/2]

LazyFileStream::~LazyFileStream ( )

Close the file and free the buffers.

Ghidra address:
0x1002cdde

Member Function Documentation

◆ Eof() [1/2]

bool LazyFileStream::Eof ( ) const

Report whether the last read reached the end of the file.

Returns
Whether no read remains.
Ghidra address:
NTSC-U/C: 0x00251940
Ghidra address:
PAL: 0x0025a2e8

◆ ReadDone() [1/2]

bool LazyFileStream::ReadDone ( )

Report whether the read in flight is complete, recording how many bytes arrived.

Returns
Whether the read is complete.
Ghidra address:
NTSC-U/C: 0x00251990
Ghidra address:
PAL: 0x0025a338

◆ GetData() [1/2]

char * LazyFileStream::GetData ( int * pnPosition,
int * pnBytesAvailable )

Take the buffer of the completed read, and start the next read unless the file ended.

Parameters
pnPositionReceives the offset of the buffer's data in the file.
pnBytesAvailableReceives the number of bytes in the buffer.
Returns
The buffer.
Ghidra address:
NTSC-U/C: 0x002519e0
Ghidra address:
PAL: 0x0025a388

◆ Eof() [2/2]

bool LazyFileStream::Eof ( ) const

Report whether the last read reached the end of the file.

Returns
Whether no read remains.
Ghidra address:
0x1002ce6c

◆ ReadDone() [2/2]

bool LazyFileStream::ReadDone ( )

Report whether the read in flight is complete, recording how many bytes arrived.

Returns
Whether the read is complete.
Ghidra address:
0x1002cf0c

◆ GetData() [2/2]

char * LazyFileStream::GetData ( int * position,
int * bytesAvailable )

Take the buffer of the completed read, and start the next read unless the file ended.

Parameters
positionReceives the offset of the buffer's data in the file.
bytesAvailableReceives the number of bytes in the buffer.
Returns
The buffer.
Ghidra address:
0x1002cf49

The documentation for this class was generated from the following files: