wavelength 1.0.0
Loading...
Searching...
No Matches
File Class Referenceabstract

Open file of the host or the disc. More...

#include <file.h>

Inheritance diagram for File:

Public Types

enum  Mode { kModeRead = 1 , kModeWrite = 2 }
 Open modes of New(). More...

Public Member Functions

virtual ~File ()
 Close the file.
virtual int Read (void *pBuffer, int nBytes)=0
 Read bytes and wait for them.
virtual bool ReadAsync (void *pBuffer, int nBytes)=0
 Start reading bytes.
virtual int Write (const void *pBuffer, int nBytes)=0
 Write bytes.
virtual int Seek (int nOffset, int nOrigin)=0
 Move the position.
virtual int Tell ()=0
 Report the position.
virtual void Flush ()=0
 Write out buffered bytes.
virtual bool Eof ()=0
 Report whether the position is at the end.
virtual bool Fail ()=0
 Report whether an operation failed.
virtual int Size ()=0
 Report the size.
virtual int UncompressedSize ()=0
 Report the size before compression.
virtual bool ReadDone (int *pnBytes)=0
 Report whether the read ReadAsync() started is complete.
virtual ~File ()
 Close the file.
virtual int Read (void *data, int bytes)=0
 Read bytes and wait for them.
virtual bool ReadAsync (void *data, int bytes)=0
 Start a read that ReadDone() finishes.
virtual int Write (const void *data, int bytes)=0
 Write bytes.
virtual int Seek (int offset, int origin)=0
 Move the position.
virtual int Tell ()=0
virtual void Flush ()=0
 Write out buffered data.
virtual bool Eof ()=0
virtual bool Fail ()=0
virtual int Size ()=0
virtual int UncompressedSize ()=0
virtual bool ReadDone (int *bytes)=0
 Report whether the read ReadAsync() started has finished.

Static Public Member Functions

static File * New (const char *pszPath, int nMode, int nFlags)
 Open a file.

Static Public Attributes

static constexpr int kFlagNoArchive = 1
 The open flags New() takes to read even a disc file through AsyncFile.

Detailed Description

Open file of the host or the disc.

An open file, read from the archive, the disc, or the host.

The RTTI includes the class name. The class is polymorphic, each kind of storage implements it, and the members after the destructor are pure in this class.

The RTTI records the class. It has no members, and its subclasses provide every operation.

Member Enumeration Documentation

◆ Mode

enum File::Mode

Open modes of New().

Enumerator
kModeRead 

Read the file.

kModeWrite 

Write the file.

Constructor & Destructor Documentation

◆ ~File() [1/2]

virtual File::~File ( )
inlinevirtual

Close the file.

Ghidra address:
NTSC-U/C: 0x003a7e58
Ghidra address:
PAL: 0x00416b38

◆ ~File() [2/2]

virtual File::~File ( )
virtual

Close the file.

Ghidra address:
0x1000dec0

Member Function Documentation

◆ New()

File * File::New ( const char * pszPath,
int nMode,
int nFlags )
static

Open a file.

A file read from the disc comes from the archive through ArkFile unless nFlags is kFlagNoArchive. Every other file is an AsyncFile. While the trace is on, the path of each file opened to read is written to the trace log.

Parameters
pszPathThe path.
nModeThe open mode, one or more of Mode.
nFlagsThe open flags.
Returns
The file, or null when it did not open.
Ghidra address:
NTSC-U/C: 0x00289330
Ghidra address:
PAL: 0x00292b28

◆ Read() [1/2]

virtual int File::Read ( void * pBuffer,
int nBytes )
pure virtual

Read bytes and wait for them.

Parameters
pBufferReceives the bytes.
nBytesThe number of bytes.
Returns
The number of bytes read.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ ReadAsync() [1/2]

virtual bool File::ReadAsync ( void * pBuffer,
int nBytes )
pure virtual

Start reading bytes.

ReadDone() reports when they arrived.

Parameters
pBufferReceives the bytes.
nBytesThe number of bytes.
Returns
Whether the read started.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Write() [1/2]

virtual int File::Write ( const void * pBuffer,
int nBytes )
pure virtual

Write bytes.

Parameters
pBufferThe bytes.
nBytesThe number of bytes.
Returns
The number of bytes written.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Seek() [1/2]

virtual int File::Seek ( int nOffset,
int nOrigin )
pure virtual

Move the position.

Parameters
nOffsetThe offset.
nOriginThe origin of the offset, 0 for the start, 1 for the position, and 2 for the end.
Returns
The new position.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Tell() [1/2]

virtual int File::Tell ( )
pure virtual

Report the position.

Returns
The position.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Flush() [1/2]

virtual void File::Flush ( )
pure virtual

Write out buffered bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Eof() [1/2]

virtual bool File::Eof ( )
pure virtual

Report whether the position is at the end.

Returns
Whether the end was arrived at.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Fail() [1/2]

virtual bool File::Fail ( )
pure virtual

Report whether an operation failed.

Returns
Whether an operation failed.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Size() [1/2]

virtual int File::Size ( )
pure virtual

Report the size.

Returns
The size in bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ UncompressedSize() [1/2]

virtual int File::UncompressedSize ( )
pure virtual

Report the size before compression.

Returns
The size in bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ ReadDone() [1/2]

virtual bool File::ReadDone ( int * pnBytes)
pure virtual

Report whether the read ReadAsync() started is complete.

Parameters
pnBytesReceives the number of bytes read.
Returns
Whether the read is complete.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Read() [2/2]

virtual int File::Read ( void * data,
int bytes )
pure virtual

Read bytes and wait for them.

Parameters
dataReceives the bytes.
bytesThe number of bytes.
Returns
The number of bytes read.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ ReadAsync() [2/2]

virtual bool File::ReadAsync ( void * data,
int bytes )
pure virtual

Start a read that ReadDone() finishes.

Parameters
dataReceives the bytes.
bytesThe number of bytes.
Returns
Whether the read started.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Write() [2/2]

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

Write bytes.

Parameters
dataThe bytes.
bytesThe number of bytes.
Returns
The number of bytes written.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Seek() [2/2]

virtual int File::Seek ( int offset,
int origin )
pure virtual

Move the position.

Parameters
offsetThe offset in bytes.
origin0 from the start, 1 from the position, 2 from the end.
Returns
The new position, or a negative value on failure.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Tell() [2/2]

virtual int File::Tell ( )
pure virtual
Returns
The position in bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Flush() [2/2]

virtual void File::Flush ( )
pure virtual

Write out buffered data.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Eof() [2/2]

virtual bool File::Eof ( )
pure virtual
Returns
Whether the position is at the end.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Fail() [2/2]

virtual bool File::Fail ( )
pure virtual
Returns
Whether an operation failed.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ Size() [2/2]

virtual int File::Size ( )
pure virtual
Returns
The size of the file as stored, in bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ UncompressedSize() [2/2]

virtual int File::UncompressedSize ( )
pure virtual
Returns
The size of the file after decompression, in bytes.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

◆ ReadDone() [2/2]

virtual bool File::ReadDone ( int * bytes)
pure virtual

Report whether the read ReadAsync() started has finished.

Parameters
bytesReceives the number of bytes read.
Returns
Whether the read has finished.

Implemented in ArkFile, ArkFile, AsyncFile, and AsyncFile.

Member Data Documentation

◆ kFlagNoArchive

int File::kFlagNoArchive = 1
staticconstexpr

The open flags New() takes to read even a disc file through AsyncFile.


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