resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::FilePath Class Reference

File name that the renderer resolves against a shared root directory. More...

#include <filepath.h>

Inheritance diagram for Rnd::FilePath:
Collaboration diagram for Rnd::FilePath:

Public Member Functions

 FilePath ()
 Construct an empty path.
 FilePath (const char *pszText)
 Construct a path from text without normalising it.
void SetFromRoot (const HxStr &name)
 Set the path to name under sRoot.
void Set (const HxStr &path)
 Set the path to path verbatim, then normalise it.
void Normalize ()
 Lowercase the path, turn backslashes into slashes, and resolve its components.
const HxStr & RelativeToRoot () const
 Express the path relative to sRoot.
void Print (Dbg &sink) const
 Write the path to sink in double quotes.
void Save (Stream &stream) const
 Write the path relative to sRoot, with its terminator, to stream.
void Load (Stream &stream)
 Read a name from stream and set the path to it under sRoot.
Public Member Functions inherited from HxStr
 HxStr ()
 Construct an empty string.
 HxStr (const char *pszText)
 Construct a copy of a C string.
 HxStr (const HxStr &other)
 Construct a copy of another string.
 HxStr (unsigned nCount, char ch)
 Construct a run of one repeated character.
 ~HxStr ()
HxStr & operator+= (const HxStr &other)
 Append another string.
HxStr & operator+= (const char *pszText)
 Append a C string.
HxStr & operator+= (char ch)
 Append one character.
HxStr & operator= (const char *pszText)
 Replace this string with a copy of a C string.
HxStr & operator= (const HxStr &other)
 Replace this string with a copy of another.
char operator[] (unsigned i) const
 Read one character.
bool operator!= (const char *pszRight) const
 Compare against a C string for inequality.
bool operator!= (const HxStr &right) const
 Compare against another string for inequality.
bool operator== (const char *pszRight) const
 Compare against a C string for equality.
bool operator== (const HxStr &right) const
 Compare against another string for equality.
bool operator< (const HxStr &right) const
 Order against another string.
void Alloc (unsigned nLen)
 Discard the text and reserve a zero-filled buffer.
int Find (char ch) const
 Find the first occurrence of a character.
int Find (char ch, unsigned nStart) const
 Find the first occurrence of a character at or after a position.
int Find (const char *pszText) const
 Find the first occurrence of a substring.
int ReverseFind (char ch) const
 Find the last occurrence of a character.
int ReverseFindOneOf (const char *pszChars) const
 Find the last occurrence of any of a set of characters.
int Compare (unsigned pos, unsigned len, const char *str) const
 Compare a run of this string against a C string.
HxStr Mid (unsigned pos) const
 Extract the text from a position to the end.
HxStr Mid (unsigned pos, unsigned len) const
 Extract a run of text.
HxStr & Replace (unsigned pos, unsigned len, char ch)
 Overwrite one character.
HxStr & Replace (unsigned pos, unsigned len, const HxStr &other)
 Overwrite a run of text with another string.
HxStr & Clear ()
 Empty the string in place.
HxStr & Truncate (unsigned pos)
 Shorten the string in place.
HxStr & Erase (unsigned pos, unsigned len)
 Remove a run of text.
HxStr & Insert (unsigned pos, unsigned nCount, char ch)
 Insert a run of one repeated character.
HxStr & Insert (unsigned pos, const HxStr &other)
 Insert another string.
std::ostream & Print (std::ostream &stream) const
 Write this string to a stream.

Static Public Member Functions

static void SetRoot (const HxStr &root)
 Replace sRoot and normalise it.
static bool IsAbsolute (const HxStr &path)
 Report whether a path names its location outright rather than relative to sRoot.

Static Public Attributes

static FilePath sRoot
 Directory every relative path is resolved against, empty until SetRoot() is called.

Additional Inherited Members

Public Attributes inherited from HxStr
unsigned mLen
 Length excluding the terminator.
char * mStr
 Text buffer.

Detailed Description

File name that the renderer resolves against a shared root directory.

The class emits no RTTI, and its name is inferred from the later Milo engine, whose FilePath plays the same part. Its routines sit in the Rnd::Tex translation unit and take the address of a string member rather than of a texture: Rnd::Tex's bitmap path and Rnd::Movie::mFilename are the two strings they operate on. A path is stored normalised, in lowercase with forward slashes and with . and .. components resolved, and it is written to a file relative to sRoot so that a saved record does not depend on where the data was installed.

The class adds no data member to HxStr, so a path is laid out exactly as the string it wraps.

Constructor & Destructor Documentation

◆ FilePath() [1/2]

Rnd::FilePath::FilePath ( )
inline

Construct an empty path.

◆ FilePath() [2/2]

Rnd::FilePath::FilePath ( const char * pszText)
inlineexplicit

Construct a path from text without normalising it.

Parameters
pszTextThe text.

Member Function Documentation

◆ SetFromRoot()

void Rnd::FilePath::SetFromRoot ( const HxStr & name)

Set the path to name under sRoot.

An empty name clears the path. Otherwise the result is sRoot, a slash, and name, normalised. The name is inferred.

Parameters
nameThe file name, relative to sRoot.
Ghidra address:
NTSC-U/C: 0x004e4bd8
Ghidra address:
PAL: 0x005234b0

◆ Set()

void Rnd::FilePath::Set ( const HxStr & path)

Set the path to path verbatim, then normalise it.

The name is inferred.

Parameters
pathThe full path.
Ghidra address:
NTSC-U/C: 0x004e7b70
Ghidra address:
PAL: 0x00526620

◆ Normalize()

void Rnd::FilePath::Normalize ( )

Lowercase the path, turn backslashes into slashes, and resolve its components.

The path is split on slashes. A .. component removes the component before it, and every other component that begins with a full stop is dropped, . included. The shipped build treats a name such as .hidden the same way. The remaining components are joined with single slashes, so a leading slash is not preserved. The name is inferred.

Ghidra address:
NTSC-U/C: 0x004e4d88
Ghidra address:
PAL: 0x005236d8

◆ RelativeToRoot()

const HxStr & Rnd::FilePath::RelativeToRoot ( ) const

Express the path relative to sRoot.

The leading components the path shares with sRoot are dropped. Each remaining component of sRoot contributes a .., and the remaining components of the path follow. The result lives in a function-local static string, so it is valid only until the next call. An empty path is returned unchanged. The name is inferred.

Returns
The relative path.
Ghidra address:
NTSC-U/C: 0x004e5168
Ghidra address:
PAL: 0x00523af0

◆ Print()

void Rnd::FilePath::Print ( Dbg & sink) const

Write the path to sink in double quotes.

Parameters
sinkThe text sink.
Ghidra address:
NTSC-U/C: 0x004e7bc0
Ghidra address:
PAL: 0x00526680

◆ Save()

void Rnd::FilePath::Save ( Stream & stream) const

Write the path relative to sRoot, with its terminator, to stream.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x004e7bf8
Ghidra address:
PAL: 0x005266b8

◆ Load()

void Rnd::FilePath::Load ( Stream & stream)

Read a name from stream and set the path to it under sRoot.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x004e7c50
Ghidra address:
PAL: 0x00526710

◆ SetRoot()

void Rnd::FilePath::SetRoot ( const HxStr & root)
static

Replace sRoot and normalise it.

Rnd::AsyncLoader::PollAsyncLoads(), ScriptSaveRnd(), and a routine at 0x004162cc call it. The name is inferred.

Parameters
rootThe new root directory.
Ghidra address:
NTSC-U/C: 0x004e78d8
Ghidra address:
PAL: 0x00526388

◆ IsAbsolute()

bool Rnd::FilePath::IsAbsolute ( const HxStr & path)
static

Report whether a path names its location outright rather than relative to sRoot.

A path that starts with a slash or a backslash, or whose second character is a colon, is absolute. So is an empty path. Rnd::Tex::SetBitmapConfig() is the one caller. The name is inferred.

Parameters
pathThe path to test.
Returns
True for an absolute path.
Ghidra address:
NTSC-U/C: 0x004e7cd8
Ghidra address:
PAL: 0x005267c8

Member Data Documentation

◆ sRoot

FilePath Rnd::FilePath::sRoot
static

Directory every relative path is resolved against, empty until SetRoot() is called.

The Rnd::Tex unit's static initialiser constructs it after Rnd::Tex::sClassName.

Ghidra address:
NTSC-U/C: 0x007033b8
Ghidra address:
PAL: 0x00746e68

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