wavelength 1.0.0
Loading...
Searching...
No Matches
File.h File Reference
#include "utl/Str.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...

Enumerations

enum  FileOpenMode { FILE_OPEN_WRITE = 1 , FILE_OPEN_READ = 2 , FILE_OPEN_CREATE = 0x100 , FILE_OPEN_TRUNCATE = 0x200 }
 Bits of the open mode of NewFile(). More...

Functions

File * NewFile (const char *name, int mode, int flags)
 Open a file from the archive or the host.
void FileLogInit (const char *file)
 Open the file log, which lists every file the program reads.
void FileInit ()
 Read the asynchronous file configuration.
void FileTerminate ()
 Close the file log.
void FileMakeLocalPath (String &out, const char *path)
 Store a path as the host opens it.
void FileCopyPath (char *out, int size, const char *path)
 Copy a path, or store an empty string for a null path.
const char * FileRoot ()
 Report the working directory at the first call, normalised.
const char * FileNormalizePath (const char *path)
 Lower-case a path, turn backslashes into slashes, and resolve .
const char * FileRelativePath (const char *path, const char *root)
 Express a path relative to a directory, both normalised.
bool FileIsAbsolute (const char *path)
 Report whether a path is absolute.
const char * FileGetPath (const char *path)
 Report the directory of a path.
const char * FileGetExt (const char *path)
 Report the extension of a path.
const char * FileGetBase (const char *path)
 Report the file name of a path without its directory or extension.
const char * FileLocalize (const char *path)
 Express a path relative to the root, as the archive indexes it.

Enumeration Type Documentation

◆ FileOpenMode

Bits of the open mode of NewFile().

The low bits pass through to _open.

Enumerator
FILE_OPEN_WRITE 

Open for writing.

FILE_OPEN_READ 

Open for reading.

FILE_OPEN_CREATE 

Create the file when it does not exist.

FILE_OPEN_TRUNCATE 

Discard the contents of an existing file.

Function Documentation

◆ NewFile()

File * NewFile ( const char * name,
int mode,
int flags )

Open a file from the archive or the host.

A read from the disc comes from the archive unless the flags are 1. When the file log is open, each read appends the file's path relative to the root to the log.

Parameters
nameThe path.
modeThe open mode, a combination of FileOpenMode bits.
flags1 to bypass the archive.
Returns
The file, or null when it did not open.
Ghidra address:
0x1000a9a0

◆ FileLogInit()

void FileLogInit ( const char * file)

Open the file log, which lists every file the program reads.

Parameters
fileThe path of the log, or null or empty for no log.
Ghidra address:
0x1000a940

◆ FileInit()

void FileInit ( )

Read the asynchronous file configuration.

Ghidra address:
0x1000a970

◆ FileTerminate()

void FileTerminate ( )

Close the file log.

Ghidra address:
0x1000a980

◆ FileMakeLocalPath()

void FileMakeLocalPath ( String & out,
const char * path )

Store a path as the host opens it.

On Windows the path is unchanged.

Parameters
outReceives the path.
pathThe path.
Ghidra address:
0x1000aad0

◆ FileCopyPath()

void FileCopyPath ( char * out,
int size,
const char * path )

Copy a path, or store an empty string for a null path.

Parameters
outReceives the path.
sizeThe size of #out. The copy does not limit itself to it.
pathThe path, or null.
Ghidra address:
0x1000ab10

◆ FileRoot()

const char * FileRoot ( )

Report the working directory at the first call, normalised.

Returns
The directory, in a static buffer.
Ghidra address:
0x1000ab50

◆ FileNormalizePath()

const char * FileNormalizePath ( const char * path)

Lower-case a path, turn backslashes into slashes, and resolve .

and .. components.

Every component that starts with a dot and is not .. is dropped. A path that ends in .. normalises to the empty string.

Parameters
pathThe path.
Returns
The normalised path, in a static buffer.
Ghidra address:
0x1000abb0

◆ FileRelativePath()

const char * FileRelativePath ( const char * path,
const char * root )

Express a path relative to a directory, both normalised.

Parameters
pathThe path.
rootThe directory.
Returns
The relative path, in a static buffer.
Ghidra address:
0x1000ad50

◆ FileIsAbsolute()

bool FileIsAbsolute ( const char * path)

Report whether a path is absolute.

Parameters
pathThe path, or null.
Returns
Whether the path is null, empty, starts with a slash or a backslash, or has a drive.
Ghidra address:
0x1000b1e0

◆ FileGetPath()

const char * FileGetPath ( const char * path)

Report the directory of a path.

Parameters
pathThe path, or null.
Returns
The directory, or . when the path has none, in a static buffer.
Ghidra address:
0x1000b210

◆ FileGetExt()

const char * FileGetExt ( const char * path)

Report the extension of a path.

Parameters
pathThe path.
Returns
The text after the last dot, or the empty string at the end of the path.
Ghidra address:
0x1000b290

◆ FileGetBase()

const char * FileGetBase ( const char * path)

Report the file name of a path without its directory or extension.

Parameters
pathThe path.
Returns
The name, in a static buffer.
Ghidra address:
0x1000b2c0

◆ FileLocalize()

const char * FileLocalize ( const char * path)

Express a path relative to the root, as the archive indexes it.

Parameters
pathThe path, absolute or relative to the root.
Returns
The relative path, in a static buffer.
Ghidra address:
0x1000e520