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

IReadOnlyList<ApplicationConfig>

CurrentConfig

Current application config.

public static ApplicationConfig CurrentConfig { get; }

Property Value

ApplicationConfig

CurrentGamePath

Directory containing the current application/game's assets.

public static string CurrentGamePath { get; }

Property Value

string

EngineConfig

The current engine configuration.

public static EngineConfig EngineConfig { get; }

Property Value

EngineConfig

EnginePath

Directory containing the engine's base assets.

public static string EnginePath { get; }

Property Value

string

Methods

Exists(string, PathFlags, bool, bool)

public static bool Exists(string path, PathFlags flags = PathFlags.All, bool excludeOtherMountedDirectories = false, bool onlyRootPath = false)

Parameters

path string

The relative path to be checked.

flags PathFlags

Filter flags.

excludeOtherMountedDirectories bool

If 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 string

A directory such as "maps" or "models/vegetation".

searchPattern string

The search pattern to filter out directory names.

recursive bool

Whether or not to scan subfolders too.

Returns

string[]

A list of directories relative to directory, null if directory 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

directory string
searchPattern string
flags PathFlags
recursive bool

Returns

string[]

GetFiles(string, string, bool)

public static string[]? GetFiles(string directory, string searchPattern = "*", bool recursive = false)

Parameters

directory string

A directory such as "maps" or "models/vegetation".

searchPattern string

The search pattern to filter out filenames.

recursive bool

Whether or not to scan subfolders too.

Returns

string[]

A list of files relative to directory, null if directory doesn't exist in any mounted path.

Init(in LaunchConfig)

public static bool Init(in LaunchConfig config)

Parameters

config LaunchConfig

Returns

bool

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 string

The directory to mount.

mountOthers bool

Mount other dirs referenced by the config?

isBase bool
isEngine 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 string

Relative path to the destination.

flags PathFlags

Filter flags.

excludeOtherMountedDirectories bool

If 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.