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

BinStream that reads or writes a file. More...

#include <filestream.h>

Inheritance diagram for FileStream:
Collaboration diagram for FileStream:

Public Types

enum  FileType { kRead = 0 , kWrite = 1 }
 How the file is opened. More...
Public Types inherited from BinStream
enum  SeekType {
  kSeekBegin = 0 , kSeekCurrent = 1 , kSeekEnd = 2 , kSeekBegin = 0 ,
  kSeekCurrent = 1 , kSeekEnd = 2
}
 Origins of Seek(). More...
enum  SeekType {
  kSeekBegin = 0 , kSeekCurrent = 1 , kSeekEnd = 2 , kSeekBegin = 0 ,
  kSeekCurrent = 1 , kSeekEnd = 2
}
 The origin of Seek(). More...

Public Member Functions

 FileStream (const char *pszPath, bool bWrite, bool bLittleEndian, int nFlags)
 Open a file.
 ~FileStream () override
 Close the file.
void Read (void *pData, int nBytes) override
 Read bytes, recording a failure when fewer arrive.
void Write (const void *pData, int nBytes) override
 Write bytes, recording a failure when fewer are written.
void Flush () override
 Write out buffered data.
void Seek (int nOffset, SeekType eFrom) override
 Move the position.
int Tell () override
 Report the position.
bool Eof () override
 Report whether the position is at the end.
bool Fail () override
 Report whether an operation failed.
File * GetFile () const
 FileStream (const char *file, FileType type, bool littleEndian, int flags)
 Open a file.
virtual ~FileStream ()
 Close the file.
virtual void Read (void *data, int bytes)
 Read bytes.
virtual void Write (const void *data, int bytes)
 Write bytes.
virtual void Flush ()
 Write out the file's buffered data.
virtual void Seek (int offset, SeekType type)
 Move the position.
virtual int Tell ()
virtual bool Eof ()
virtual bool Fail ()
Public Member Functions inherited from BinStream
 BinStream (bool bLittleEndian)
 Construct a stream.
virtual ~BinStream ()
 Release the stream.
virtual void Mark (const char *pszMark)
 Receive a named mark in the data, such as the end of a chunk.
void ReadString (char *pszBuffer, int nSize)
 Read a length-prefixed string into a buffer and terminate it.
void ReadString (String &text)
 Read a length-prefixed string.
BinStream & WriteString (const char *pszText)
 Write a string with its length first.
void ReadEndian (void *pData, int nBytes)
 Read a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
void WriteEndian (const void *pData, int nBytes)
 Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
 BinStream (bool littleEndian)
 Set the byte order.
virtual ~BinStream ()
 Destroy the stream.
virtual void NoOp (int)
 Do nothing.
void ReadEndian (void *data, int bytes)
 Read a value, swapping its bytes into the host order.
void WriteEndian (const void *data, int bytes)
 Write a value, swapping its bytes into the stream order.
BinStream & operator<< (const char *str)
 Write text as its length followed by its characters, without a terminator.
BinStream & operator>> (String &str)
 Read text written by operator<<(const char *).
void ReadString (char *buffer, int bufSize)
 Read text written by operator<<(const char *) into a buffer, and terminate it.
BinStream & operator<< (char c)
BinStream & operator<< (unsigned char c)
BinStream & operator<< (short s)
BinStream & operator<< (unsigned short s)
BinStream & operator<< (int i)
BinStream & operator<< (unsigned int i)
BinStream & operator<< (float f)
BinStream & operator>> (char &c)
BinStream & operator>> (unsigned char &c)
BinStream & operator>> (short &s)
BinStream & operator>> (unsigned short &s)
BinStream & operator>> (int &i)
BinStream & operator>> (unsigned int &i)
BinStream & operator>> (float &f)

Detailed Description

BinStream that reads or writes a file.

Stream over a file.

The RTTI includes the class name and records BinStream as the base. Only the members its callers here use are declared.

The RTTI records the class as deriving from BinStream. The object is 0x10 bytes. Every transfer asserts that no earlier one failed.

Member Enumeration Documentation

◆ FileType

How the file is opened.

Enumerator
kRead 

Open an existing file for reading.

kWrite 

Create or truncate the file for writing.

Constructor & Destructor Documentation

◆ FileStream() [1/2]

FileStream::FileStream ( const char * pszPath,
bool bWrite,
bool bLittleEndian,
int nFlags )

Open a file.

Parameters
pszPathThe path of the file.
bWriteOpen the file for writing, creating or truncating it.
bLittleEndianStore values in the console's byte order.
nFlagsPassed to the routine that opens the file.
Ghidra address:
NTSC-U/C: 0x00299588
Ghidra address:
PAL: 0x002a3198

◆ ~FileStream() [1/2]

FileStream::~FileStream ( )
override

Close the file.

Ghidra address:
NTSC-U/C: 0x00299610
Ghidra address:
PAL: 0x002a3220

◆ FileStream() [2/2]

FileStream::FileStream ( const char * file,
FileType type,
bool littleEndian,
int flags )

Open a file.

The stream fails when the file does not open.

Parameters
fileThe path.
typeHow the file is opened.
littleEndianWhether values are stored least significant byte first.
flagsPassed to NewFile(); 1 bypasses the archive.
Ghidra address:
0x10011db0

◆ ~FileStream() [2/2]

virtual FileStream::~FileStream ( )
virtual

Close the file.

Ghidra address:
0x10011e80

Member Function Documentation

◆ Read() [1/2]

void FileStream::Read ( void * pData,
int nBytes )
overridevirtual

Read bytes, recording a failure when fewer arrive.

Parameters
pDataThe destination.
nBytesThe number of bytes.
Ghidra address:
NTSC-U/C: 0x00299688
Ghidra address:
PAL: 0x002a3288

Implements BinStream.

◆ Write() [1/2]

void FileStream::Write ( const void * pData,
int nBytes )
overridevirtual

Write bytes, recording a failure when fewer are written.

Parameters
pDataThe source.
nBytesThe number of bytes.
Ghidra address:
NTSC-U/C: 0x002996d8
Ghidra address:
PAL: 0x002a32d8

Implements BinStream.

◆ Flush() [1/2]

void FileStream::Flush ( )
overridevirtual

Write out buffered data.

Ghidra address:
NTSC-U/C: 0x00299728
Ghidra address:
PAL: 0x002a3328

Implements BinStream.

◆ Seek() [1/2]

void FileStream::Seek ( int nOffset,
SeekType eFrom )
overridevirtual

Move the position.

Parameters
nOffsetThe offset in bytes.
eFromThe origin of the offset.
Ghidra address:
NTSC-U/C: 0x00299758
Ghidra address:
PAL: 0x002a3358

Implements BinStream.

◆ Tell() [1/2]

int FileStream::Tell ( )
overridevirtual

Report the position.

Returns
The position in bytes.
Ghidra address:
NTSC-U/C: 0x002997d0
Ghidra address:
PAL: 0x002a33d0

Implements BinStream.

◆ Eof() [1/2]

bool FileStream::Eof ( )
overridevirtual

Report whether the position is at the end.

Returns
Whether no byte is left.
Ghidra address:
NTSC-U/C: 0x00299800
Ghidra address:
PAL: 0x002a3400

Implements BinStream.

◆ Fail() [1/2]

bool FileStream::Fail ( )
overridevirtual

Report whether an operation failed.

Returns
Whether an operation failed.
Ghidra address:
NTSC-U/C: 0x00299830
Ghidra address:
PAL: 0x002a3430

Implements BinStream.

◆ GetFile()

File * FileStream::GetFile ( ) const
inline
Returns
The file, or null when it did not open.

◆ Read() [2/2]

virtual void FileStream::Read ( void * data,
int bytes )
virtual

Read bytes.

A short read fails the stream.

Parameters
dataReceives the bytes.
bytesThe number of bytes.
Ghidra address:
0x10011ed0

Implements BinStream.

◆ Write() [2/2]

virtual void FileStream::Write ( const void * data,
int bytes )
virtual

Write bytes.

A short write fails the stream.

Parameters
dataThe bytes.
bytesThe number of bytes.
Ghidra address:
0x10011f20

Implements BinStream.

◆ Flush() [2/2]

virtual void FileStream::Flush ( )
virtual

Write out the file's buffered data.

Ghidra address:
0x10011f70

Implements BinStream.

◆ Seek() [2/2]

virtual void FileStream::Seek ( int offset,
SeekType type )
virtual

Move the position.

A negative result fails the stream.

Parameters
offsetThe offset in bytes.
typeThe origin of the offset.
Ghidra address:
0x10011fb0

Implements BinStream.

◆ Tell() [2/2]

virtual int FileStream::Tell ( )
virtual
Returns
The position in bytes.
Ghidra address:
0x10012020

Implements BinStream.

◆ Eof() [2/2]

virtual bool FileStream::Eof ( )
virtual
Returns
Whether the position is at the end of the file.
Ghidra address:
0x10012060

Implements BinStream.

◆ Fail() [2/2]

virtual bool FileStream::Fail ( )
virtual
Returns
Whether the file did not open or a transfer failed.
Ghidra address:
0x100120a0

Implements BinStream.


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