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
pathstringThe relative path to be checked.
flagsPathFlagsFilter flags.
excludeOtherMountedDirectoriesboolIf true, only search in engine dir and base dir.
onlyRootPathbool
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
directorystringA directory such as
"maps"or"models/vegetation".searchPatternstringThe search pattern to filter out directory names.
recursiveboolWhether or not to scan subfolders too.
Returns
- string[]
A list of directories relative to
directory,nullifdirectorydoesn'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
directorystringA directory such as
"maps"or"models/vegetation".searchPatternstringThe search pattern to filter out filenames.
recursiveboolWhether or not to scan subfolders too.
Returns
- string[]
A list of files relative to
directory,nullifdirectorydoesn't exist in any mounted path.
Init(in LaunchConfig)
public static bool Init(in LaunchConfig config)
Parameters
configLaunchConfig
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
directorystringThe directory to mount.
mountOthersboolMount other dirs referenced by the config?
isBaseboolisEnginebool
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
destinationstringRelative path to the destination.
flagsPathFlagsFilter flags.
excludeOtherMountedDirectoriesboolIf true, only search in engine dir and base dir.
onlyRootPathbool
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
directorystring
Returns
- bool
True if successfully unmounted, false if the directory was already not mounted.