wavelength 1.0.0
Loading...
Searching...
No Matches
file.h File Reference
#include <vector>
#include "os/string.h"
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  File
 Open file of the host or the disc. More...
struct  FileStat
 Status of a host file FileGetStat() reports. More...

Functions

void FormatDevicePath (char *pszDest, int nSize, const char *pszFile)
 Format the device path of a game file.
void MakeDevicePath (String &path, const char *pszFile)
 Build the device path of a game file.
void FileSetBootPath (const char *pszPath)
 Record the path the executable was started from, without its device and version.
const char * FileBootExecutable ()
 Report the path FileSetBootPath() recorded.
void FileOpenTraceLog (const char *pszPath)
 Open the trace log that File::New() writes the path of each file read to, and turn the trace on.
void FileSetTraceEnabled (int nEnabled)
 Turn the trace of File::New() on or off.
int FileIsTraceEnabled ()
 Report whether the trace of File::New() is on.
void FileInit ()
 Read the file settings of the system configuration.
void FileTerminate ()
 Close the trace log.
void FileNoteRead (const char *pszPath)
 Note the first read of a file.
int FileGetStat (const char *pszPath, FileStat *pStat)
 Report the status of a host file.
int FileMkDir (const char *pszPath)
 Create a host directory.
char FileSourceLetter ()
 Report the letter the module loader puts in front of a module's source.

Variables

constexpr int kImageFirstWord = 0
 The word at 0x00100000, the load address of the executable.
constexpr int kImageSecondWord = 0
 The word at 0x00100004.
std::vector< File * > gFileTable
 Files the gzip reader reads by descriptor, 128 entries.

Function Documentation

◆ FormatDevicePath()

void FormatDevicePath ( char * pszDest,
int nSize,
const char * pszFile )

Format the device path of a game file.

When the game runs from the disc, the path is cdrom0:\\endiskip and the file upper-cased, with backslashes for slashes and a ;1 version suffix. Otherwise it is host0: and the file.

Parameters
pszDestReceives the path.
nSizeThe size of pszDest, which is not checked.
pszFileThe file, relative to the root of the game files, or null for an empty path.
Ghidra address:
NTSC-U/C: 0x002894e8
Ghidra address:
PAL: 0x00292ce0

◆ MakeDevicePath()

void MakeDevicePath ( String & path,
const char * pszFile )

Build the device path of a game file.

The name is inferred.

Parameters
pathReceives the path FormatDevicePath() formats.
pszFileThe file, relative to the root of the game files.
Ghidra address:
NTSC-U/C: 0x002894a8
Ghidra address:
PAL: 0x00292ca0

◆ FileSetBootPath()

void FileSetBootPath ( const char * pszPath)

Record the path the executable was started from, without its device and version.

Also opens an AsyncFile with an empty path, which is retained and never read.

Parameters
pszPathThe path the executable was started from.
Ghidra address:
NTSC-U/C: 0x00289128
Ghidra address:
PAL: 0x00292920

◆ FileBootExecutable()

const char * FileBootExecutable ( )

Report the path FileSetBootPath() recorded.

Returns
The path.
Ghidra address:
NTSC-U/C: 0x00289260
Ghidra address:
PAL: 0x00292a58

◆ FileOpenTraceLog()

void FileOpenTraceLog ( const char * pszPath)

Open the trace log that File::New() writes the path of each file read to, and turn the trace on.

Parameters
pszPathThe path of the log, or null or empty for no log.
Ghidra address:
NTSC-U/C: 0x00289270
Ghidra address:
PAL: 0x00292a68

◆ FileSetTraceEnabled()

void FileSetTraceEnabled ( int nEnabled)

Turn the trace of File::New() on or off.

Parameters
nEnabledNon-zero to trace.
Ghidra address:
NTSC-U/C: 0x002892b0
Ghidra address:
PAL: 0x00292aa8

◆ FileIsTraceEnabled()

int FileIsTraceEnabled ( )

Report whether the trace of File::New() is on.

Returns
Non-zero while the trace is on.
Ghidra address:
NTSC-U/C: 0x002892c0
Ghidra address:
PAL: 0x00292ab8

◆ FileInit()

void FileInit ( )

Read the file settings of the system configuration.

Ghidra address:
NTSC-U/C: 0x002892d0
Ghidra address:
PAL: 0x00292ac8

◆ FileTerminate()

void FileTerminate ( )

Close the trace log.

Ghidra address:
NTSC-U/C: 0x002892f0
Ghidra address:
PAL: 0x00292ae8

◆ FileNoteRead()

void FileNoteRead ( const char * pszPath)

Note the first read of a file.

The body does nothing.

Parameters
pszPathThe device path of the file.
Ghidra address:
NTSC-U/C: 0x002894a0
Ghidra address:
PAL: 0x00292c98

◆ FileGetStat()

int FileGetStat ( const char * pszPath,
FileStat * pStat )

Report the status of a host file.

With a non-zero kImageFirstWord the status is cleared instead.

Parameters
pszPathThe file, relative to the root of the game files.
pStatReceives the status.
Returns
The result of sceGetstat(), or 0.
Ghidra address:
NTSC-U/C: 0x00289eb8
Ghidra address:
PAL: 0x002936b0

◆ FileMkDir()

int FileMkDir ( const char * pszPath)

Create a host directory.

Parameters
pszPathThe directory, relative to the root of the game files.
Returns
The result of sceMkdir(), or -1 when the game runs from the disc.
Ghidra address:
NTSC-U/C: 0x00289fa8
Ghidra address:
PAL: 0x002937a0

◆ FileSourceLetter()

char FileSourceLetter ( )

Report the letter the module loader puts in front of a module's source.

Returns
r with a non-zero kImageFirstWord, otherwise s.
Ghidra address:
NTSC-U/C: 0x0028a178
Ghidra address:
PAL: 0x00293970

Variable Documentation

◆ kImageFirstWord

int kImageFirstWord = 0
constexpr

The word at 0x00100000, the load address of the executable.

Several routines take a development-tool path while the word is non-zero. A retail image has zero there.

◆ kImageSecondWord

int kImageSecondWord = 0
constexpr

The word at 0x00100004.

The memory tracker and its allocator of development memory work only while the word is non-zero. A retail image has zero there.

◆ gFileTable

std::vector<File *> gFileTable
extern

Files the gzip reader reads by descriptor, 128 entries.

Ghidra address:
NTSC-U/C: 0x0047fdf0