Class: FS
Engine filesystem facade.
Path aliases such as $game_config$ and $logs$ are resolved by this object.
Source
C++ class FS
Custom Constructor
FS
Remarks
Mutating methods operate on real files or engine path aliases. Prefer exist, path_exist, and update_path before destructive operations.
Constructors
Constructor
new FS(): FS;Returns
FS
Methods
append_path()
append_path(
alias: string,
root: string,
path: string,
recursive: boolean): FS_Path;Add a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Alias name. |
root | string | Root path. |
path | string | Relative path. |
recursive | boolean | Whether subfolders should be scanned. |
Returns
Native filesystem path descriptor.
Remarks
Native code asserts if root is invalid or alias is already registered. On success it returns a path descriptor.
dir_delete()
Call Signature
dir_delete(
path: string,
filename: string,
remove_files: boolean): void;Delete a directory below a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path alias or root path. |
filename | string | Directory name. |
remove_files | boolean | Whether files inside should be removed. |
Returns
void
Call Signature
dir_delete(path: string, remove_files: boolean): void;Delete a directory.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Directory path. |
remove_files | boolean | Whether files inside should be removed. |
Returns
void
exist()
Call Signature
exist(
alias: string,
filename: string,
fs_type: TXR_fs_type): FileStatus;Check whether a file exists below a path alias in a selected filesystem source.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
filename | string | File name. |
fs_type | TXR_fs_type | Filesystem source to search. |
Returns
File status.
Since
OpenXRay 2014-11-02, 827c9f58
Remarks
OpenXRay extension. This overload resolves alias and filename, then checks virtual files, external files, or both according to fs_type. It always returns a FileStatus; inspect Exists for the result and External to see whether the match came from the external filesystem.
Call Signature
exist(alias: string, filename: string): Nullable<fs_file>;Get a registered file descriptor below a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
filename | string | File name. |
Returns
Nullable<fs_file>
Registered file descriptor, or null when no registered file is found.
Remarks
Original X-Ray/vanilla-compatible overload. It resolves alias and filename and searches registered virtual files only.
Call Signature
exist(path: string): Nullable<fs_file>;Get a registered file descriptor by full virtual path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
Nullable<fs_file>
Registered file descriptor, or null when no registered file is found.
Remarks
Original X-Ray/vanilla-compatible overload. It searches registered virtual files only. OpenXRay restored this overload on 2023-01-25 after external-filesystem overloads had temporarily taken the exist name.
Call Signature
exist(path: string, fs_type: TXR_fs_type): FileStatus;Check whether a file exists in a selected filesystem source.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
fs_type | TXR_fs_type | Filesystem source to search. |
Returns
File status.
Since
OpenXRay 2014-11-02, 827c9f58
Remarks
OpenXRay extension. This overload checks virtual files, external files, or both according to fs_type. It always returns a FileStatus; inspect Exists for the result and External to see whether the match came from the external filesystem.
file_copy()
file_copy(source: string, destination: string): void;Copy a file.
Parameters
| Parameter | Type | Description |
|---|---|---|
source | string | Source file path. |
destination | string | Destination file path. |
Returns
void
file_delete()
Call Signature
file_delete(path: string, filename: string): void;Delete a file below a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path alias or root path. |
filename | string | File name. |
Returns
void
Call Signature
file_delete(path: string): void;Delete a file.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
void
file_length()
file_length(path: string): number;Get file length.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
number
File length in bytes, or engine error value.
file_list_open()
Call Signature
file_list_open(
alias: string,
folder: string,
flags: number): FS_file_list;Open a file list below a path alias and folder.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
folder | string | Folder inside the alias. |
flags | number | Listing flags. |
Returns
File list.
Call Signature
file_list_open(path: string, flags: number): FS_file_list;Open a file list for a resolved path or alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path or path alias. |
flags | number | Listing flags. |
Returns
File list.
file_list_open_ex()
file_list_open_ex(
path: string,
flags: number,
mask: string): FS_file_list_ex;Open a sortable filtered file list.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path or path alias. |
flags | number | Listing flags. |
mask | string | File mask. |
Returns
Sortable file list.
Remarks
Forces the path to be rescanned before collecting matching entries.
file_rename()
file_rename(
path: string,
destination: string,
overwrite: boolean): void;Rename or move a file.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Source file path. |
destination | string | Destination file path. |
overwrite | boolean | Whether an existing destination may be overwritten. |
Returns
void
get_file_age()
get_file_age(path: string): number;Get file modification timestamp.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
number
Modification timestamp.
get_file_age_str()
get_file_age_str(path: string): number;Get file modification timestamp as packed display value.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
number
Modification timestamp value.
get_path()
get_path(alias: string): FS_Path;Get native path descriptor for an alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
Returns
Native filesystem path descriptor.
Remarks
Native code asserts when the alias is missing. Use FS.path_exist before calling when the alias is optional.
path_exist()
path_exist(path: string): boolean;Check whether a path alias exists.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path alias. |
Returns
boolean
Whether the path exists.
r_close()
r_close(reader: reader): void;Close a binary reader.
Parameters
| Parameter | Type | Description |
|---|---|---|
reader | reader | Reader returned by r_open. |
Returns
void
r_open()
Call Signature
r_open(path: string): reader;Open a binary reader.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
Binary reader.
Call Signature
r_open(alias: string, path: string): reader;Open a binary reader below a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
path | string | Relative file path. |
Returns
Binary reader.
rescan_path()
rescan_path(path: string): void;Rescan a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path alias. |
Returns
void
Since
OpenXRay 2015-07-07, 6e703b4c
Remarks
Marks the alias as needing a rescan. The next filesystem check refreshes cached entries.
update_path()
update_path(alias: string, add: string): string;Resolve path alias and suffix into a real path.
Parameters
| Parameter | Type | Description |
|---|---|---|
alias | string | Filesystem path alias. |
add | string | Relative path to append. |
Returns
string
Resolved path.
Remarks
Non-Windows builds normalize path separators before returning the string.
w_close()
w_close(writer: Nillable<IWriter>): void;Close a binary writer.
Parameters
| Parameter | Type | Description |
|---|---|---|
writer | Nillable<IWriter> | Writer returned by w_open. |
Returns
void
w_open()
Call Signature
w_open(path: string, filename: string): Nullable<IWriter>;Open a binary writer below a path alias.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Filesystem path alias. |
filename | string | Relative file path. |
Returns
Nullable<IWriter>
Binary writer, or null.
Remarks
Can return null when native writer setup fails.
Call Signature
w_open(path: string): Nullable<IWriter>;Open a binary writer.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | File path. |
Returns
Nullable<IWriter>
Binary writer, or null.
Remarks
Can return null when native writer setup fails.
Properties
FS_ClampExt
readonly static FS_ClampExt: 4;Clamp listed paths by extension.
FS_ListFiles
readonly static FS_ListFiles: 1;List files.
FS_ListFolders
readonly static FS_ListFolders: 2;List folders.
FS_RootOnly
readonly static FS_RootOnly: 8;Do not recurse into subfolders.
FS_sort_by_modif_down
readonly static FS_sort_by_modif_down: 5;Sort by modification time, newest first.
FS_sort_by_modif_up
readonly static FS_sort_by_modif_up: 4;Sort by modification time, oldest first.
FS_sort_by_name_down
readonly static FS_sort_by_name_down: 1;Sort by name descending.
FS_sort_by_name_up
readonly static FS_sort_by_name_up: 0;Sort by name ascending.
FS_sort_by_size_down
readonly static FS_sort_by_size_down: 3;Sort by size descending.
FS_sort_by_size_up
readonly static FS_sort_by_size_up: 2;Sort by size ascending.
FSType_Any
readonly static FSType_Any: 3;Search virtual and external files.
Since
OpenXRay 2014-11-02, 827c9f58
FSType_External
readonly static FSType_External: 2;Search external files only.
Since
OpenXRay 2014-11-02, 827c9f58
FSType_Virtual
readonly static FSType_Virtual: 1;Search virtual registered files only.
Since
OpenXRay 2014-11-02, 827c9f58