Class Files
- Namespace
- Elegy.FileSystem.API
- Assembly
- Elegy.FileSystem.dll
Elegy filesystem interface.
public static class Files
- Inheritance
-
Files
- Inherited Members
Properties
Configs
All application configs except the current one.
public static IReadOnlyList<ApplicationConfig> Configs { get; }
Property Value
CurrentConfig
Current application config.
public static ApplicationConfig CurrentConfig { get; }
Property Value
CurrentGamePath
Directory containing the current application/game's assets.
public static string CurrentGamePath { get; }
Property Value
EngineConfig
The current engine configuration.
public static EngineConfig EngineConfig { get; }
Property Value
EnginePath
Directory containing the engine's base assets.
public static string EnginePath { get; }
Property Value
Methods
Exists(string, PathFlags, bool, bool)
public static bool Exists(string path, PathFlags flags = PathFlags.All, bool excludeOtherMountedDirectories = false, bool onlyRootPath = false)
Parameters
path
stringThe relative path to be checked.
flags
PathFlagsFilter flags.
excludeOtherMountedDirectories
boolIf true, only search in engine dir and base dir.
onlyRootPath
bool
Returns
- bool
True if the path exists and passes the filter flags.
GetDirectories(string, string, bool)
public static string[]? GetDirectories(string directory, string searchPattern = "*", bool recursive = false)
Parameters
directory
stringA directory such as
"maps"
or"models/vegetation"
.searchPattern
stringThe search pattern to filter out directory names.
recursive
boolWhether or not to scan subfolders too.
Returns
- string[]
A list of directories relative to
directory
,null
ifdirectory
doesn't exist in any mounted path.
GetEntries(string, string, PathFlags, bool)
Similar to GetFiles(string, string, bool) and GetDirectories(string, string, bool), except it can include either filesystem entries.
Useful for implementing your own "ls"
or "dir"
console command.
public static string[]? GetEntries(string directory, string searchPattern = "*", PathFlags flags = PathFlags.All, bool recursive = false)
Parameters
Returns
- string[]
GetFiles(string, string, bool)
public static string[]? GetFiles(string directory, string searchPattern = "*", bool recursive = false)
Parameters
directory
stringA directory such as
"maps"
or"models/vegetation"
.searchPattern
stringThe search pattern to filter out filenames.
recursive
boolWhether or not to scan subfolders too.
Returns
- string[]
A list of files relative to
directory
,null
ifdirectory
doesn't exist in any mounted path.
Init(in LaunchConfig)
public static bool Init(in LaunchConfig config)
Parameters
config
LaunchConfig
Returns
Mount(string, bool, bool, bool)
Mounts an application directory. Looks for an "applicationConfig.json" inside this directory, parses it and optionally mounts other directories referenced by the config.
public static bool Mount(string directory, bool mountOthers = false, bool isBase = false, bool isEngine = false)
Parameters
directory
stringThe directory to mount.
mountOthers
boolMount other dirs referenced by the config?
isBase
boolisEngine
bool
Returns
- bool
True on success, false if the directory does not exist, the config doesn't exist and so on.
PathTo(string, PathFlags, bool, bool)
public static string? PathTo(string destination, PathFlags flags = PathFlags.All, bool excludeOtherMountedDirectories = false, bool onlyRootPath = false)
Parameters
destination
stringRelative path to the destination.
flags
PathFlagsFilter flags.
excludeOtherMountedDirectories
boolIf true, only search in engine dir and base dir.
onlyRootPath
bool
Returns
- string
Working-directory-relative path to the destination in one of the mounted dirs.
Shutdown()
public static void Shutdown()
Unmount(string)
Unmounts a directory.
public static bool Unmount(string directory)
Parameters
directory
string
Returns
- bool
True if successfully unmounted, false if the directory was already not mounted.