Class: MockFileSystem
Mock engine FS manager.
Implements
FS
Constructors
Constructor
new MockFileSystem(mocks?: Record<string, any>): MockFileSystem;Parameters
| Parameter | Type | Default value |
|---|---|---|
mocks | Record<string, any> | MockFileSystem.MOCKS |
Returns
MockFileSystem
Methods
setMock()
setMock(
root: string,
path: string,
isExisting?: boolean): void;Parameters
| Parameter | Type | Default value |
|---|---|---|
root | string | undefined |
path | string | undefined |
isExisting | boolean | true |
Returns
void
create()
static create(mocks?: Record<string, any>): MockFileSystem;Parameters
| Parameter | Type | Default value |
|---|---|---|
mocks | Record<string, any> | MockFileSystem.MOCKS |
Returns
MockFileSystem
getInstance()
static getInstance(): MockFileSystem;Returns
MockFileSystem
mock()
static mock(): MockFileSystem;Returns
MockFileSystem
Properties
append_path
append_path: Mock<(alias: string, root: string, add: string) => {
m_Add: string;
m_DefExt: string;
m_FilterCaption: string;
m_Path: string;
m_Root: string;
}>;Add a path alias.
Remarks
Native code asserts if root is invalid or alias is already registered. On success it returns a path descriptor.
Param
alias
Alias name.
Param
root
Root path.
Param
path
Relative path.
Param
recursive
Whether subfolders should be scanned.
Returns
Native filesystem path descriptor.
Implementation of
FS.append_pathdir_delete
dir_delete: Mock<() => void>;Delete a directory below a path alias.
Param
path
Path alias or root path.
Param
filename
Directory name.
Param
remove_files
Whether files inside should be removed.
Implementation of
FS.dir_deleteexist
exist: MockedFunction<{
(alias: string, filename: string, fs_type: TXR_fs_type): FileStatus;
(alias: string, filename: string): Nullable<fs_file>;
(path: string): Nullable<fs_file>;
(path: string, fs_type: TXR_fs_type): FileStatus;
}>;Check whether a file exists below a path alias in a selected filesystem source.
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.
Param
alias
Filesystem path alias.
Param
filename
File name.
Param
fs_type
Filesystem source to search.
Returns
File status.
Implementation of
FS.existfile_copy
file_copy: Mock<() => void>;Copy a file.
Param
source
Source file path.
Param
destination
Destination file path.
Implementation of
FS.file_copyfile_delete
file_delete: Mock<() => void>;Delete a file below a path alias.
Param
path
Path alias or root path.
Param
filename
File name.
Implementation of
FS.file_deletefile_length
file_length: Mock<(path: string) => -1 | 0>;Get file length.
Param
path
File path.
Returns
File length in bytes, or engine error value.
Implementation of
FS.file_lengthfile_list_open
file_list_open: Mock<() => MockFileSystemList>;Open a file list below a path alias and folder.
Param
alias
Filesystem path alias.
Param
folder
Folder inside the alias.
Param
flags
Listing flags.
Returns
File list.
Implementation of
FS.file_list_openfile_list_open_ex
file_list_open_ex: Mock<() => MockFileSystemList>;Open a sortable filtered file list.
Remarks
Forces the path to be rescanned before collecting matching entries.
Param
path
Path or path alias.
Param
flags
Listing flags.
Param
mask
File mask.
Returns
Sortable file list.
Implementation of
FS.file_list_open_exfile_rename
file_rename: Mock<() => void>;Rename or move a file.
Param
path
Source file path.
Param
destination
Destination file path.
Param
overwrite
Whether an existing destination may be overwritten.
Implementation of
FS.file_renameget_file_age
get_file_age: Mock<() => number>;Get file modification timestamp.
Param
path
File path.
Returns
Modification timestamp.
Implementation of
FS.get_file_ageget_file_age_str
get_file_age_str: Mock<() => number>;Get file modification timestamp as packed display value.
Param
path
File path.
Returns
Modification timestamp value.
Implementation of
FS.get_file_age_strget_path
get_path: Mock<(alias: string) => {
m_Add: string;
m_DefExt: string;
m_FilterCaption: string;
m_Path: string;
m_Root: string;
}>;Get native path descriptor for an alias.
Remarks
Native code asserts when the alias is missing. Use FS.path_exist before calling when the alias is optional.
Param
alias
Filesystem path alias.
Returns
Native filesystem path descriptor.
Implementation of
FS.get_pathmocks
mocks: Record<string, any>;path_exist
path_exist: Mock<(path: string) => boolean>;Check whether a path alias exists.
Param
path
Path alias.
Returns
Whether the path exists.
Implementation of
FS.path_existpaths
paths: Record<string, string>;r_close
r_close: Mock<UnknownFunction>;Close a binary reader.
Param
reader
Reader returned by r_open.
Implementation of
FS.r_closer_open
r_open: MockedFunction<{
(path: string): reader;
(alias: string, path: string): reader;
}>;Open a binary reader.
Param
path
File path.
Returns
Binary reader.
Implementation of
FS.r_openrescan_path
rescan_path: Mock<UnknownFunction>;Rescan a path alias.
Since
OpenXRay 2015-07-07, 6e703b4c
Remarks
Marks the alias as needing a rescan. The next filesystem check refreshes cached entries.
Param
path
Path alias.
Implementation of
FS.rescan_pathupdate_path
update_path: Mock<(base: string, part: string) => string>;Resolve path alias and suffix into a real path.
Remarks
Non-Windows builds normalize path separators before returning the string.
Param
alias
Filesystem path alias.
Param
add
Relative path to append.
Returns
Resolved path.
Implementation of
FS.update_pathw_close
w_close: Mock<UnknownFunction>;Close a binary writer.
Param
writer
Writer returned by w_open.
Implementation of
FS.w_closew_open
w_open: Mock<() => {
}>;Open a binary writer below a path alias.
Remarks
Can return null when native writer setup fails.
Param
path
Filesystem path alias.
Param
filename
Relative file path.
Returns
Binary writer, or null.
Implementation of
FS.w_openFS_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
MOCKS
static MOCKS: Record<string, Record<string, boolean>>;