Class VirtualFileSystem¶
Namespace: Apogee.Content.FileSystem
Assembly: Apogee.Content.dll
The engine's view of its files: res:// (the game's content, from folders and packs), user:// (what the player's machine keeps: saves, settings, mods) and
mod://<id>/ (a mod's own files), each made of mounted
public sealed class VirtualFileSystem
Inheritance¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Properties¶
Mounts¶
The mounts in the order they were added; later ones override earlier ones.
public IReadOnlyList<Mount> Mounts { get; }
Property Value¶
Methods¶
CanWrite(string)¶
Whether a write to path would be accepted: the path is valid and the mount that holds it takes writes. Nothing is written.
public bool CanWrite(string path)
Parameters¶
path string
Returns¶
CreateDirectory(string)¶
public void CreateDirectory(string path)
Parameters¶
path string
DefaultUserDirectory(string, string)¶
The folder the player's files of a game go in: <local application data>/<organization>/<game> (~/.local/share on Linux, AppData/Local
on Windows, ~/Library/Application Support on macOS).
public static string DefaultUserDirectory(string organization, string game)
Parameters¶
organization string
game string
Returns¶
Delete(string)¶
public void Delete(string path)
Parameters¶
path string
DirectoryExists(string)¶
public bool DirectoryExists(string path)
Parameters¶
path string
Returns¶
EnumerateDirectories(string)¶
The folders directly inside directory, as full paths, sorted.
public List<string> EnumerateDirectories(string directory)
Parameters¶
directory string
Returns¶
EnumerateFiles(string, string, bool, int, int)¶
The files directly in directory (or under it with recursive) whose name matches pattern (* and ?), as full paths, sorted.
public List<string> EnumerateFiles(string directory, string pattern = "*", bool recursive = false, int maxDepth = 2147483647, int maxDirectories = 2147483647)
Parameters¶
directory string
The folder to list.
pattern string
The names to keep.
recursive bool
Also list the folders below.
maxDepth int
With recursive: the deepest folder to enter (the folder itself is level 0). A link that points back at a folder above it makes a tree without end; a caller that does not trust its folders gives a limit.
maxDirectories int
With recursive: the most folders to enter. Two links back to the same folder make a tree that grows by a power of two for each level, which a depth limit alone does not stop.
Returns¶
Exceptions¶
A limit was passed.
Exists(string)¶
public bool Exists(string path)
Parameters¶
path string
Returns¶
FileExists(string)¶
public bool FileExists(string path)
Parameters¶
path string
Returns¶
KindOf(string)¶
What is at path: a file, a directory (also the root of a scheme, and the folders above a mount), or
public FileKind KindOf(string path)
Parameters¶
path string
Returns¶
Mount(string, IFileSource)¶
Mounts source at prefix, over what is mounted there already.
public void Mount(string prefix, IFileSource source)
Parameters¶
prefix string
source IFileSource
Move(string, string)¶
Moves the file at from to to, which must have no file or folder yet; the folders above it are made. Inside one source (a game folder) it is a rename; between
two sources it is a copy and then a delete. Both paths have to be writable.
public void Move(string from, string to)
Parameters¶
from string
to string
Exceptions¶
There is no file at from.
Something is already at to.
One of the paths is not in a writable source.
OpenRead(string)¶
public Stream OpenRead(string path)
Parameters¶
path string
Returns¶
ReadAllBytes(string)¶
public byte[] ReadAllBytes(string path)
Parameters¶
path string
Returns¶
byte[]
Exceptions¶
No source has the file.
The path is not valid.
ReadAllText(string)¶
The file as UTF-8 text, without a byte order mark.
public string ReadAllText(string path)
Parameters¶
path string
Returns¶
TryGetPhysicalPath(string)¶
The path of the file in the real file system, when the source that has it is a folder: for watching it, or for a library that only takes a path. Null otherwise.
public string? TryGetPhysicalPath(string path)
Parameters¶
path string
Returns¶
Unmount(IFileSource)¶
Takes source out of every prefix it is mounted at. The source is not disposed.
public bool Unmount(IFileSource source)
Parameters¶
source IFileSource
Returns¶
WriteAllBytes(string, ReadOnlySpan<byte>)¶
public void WriteAllBytes(string path, ReadOnlySpan<byte> bytes)
Parameters¶
path string
bytes ReadOnlySpan<byte>
Exceptions¶
The path is not in a writable source (only user:// is one by default).
WriteAllText(string, string)¶
public void WriteAllText(string path, string text)
Parameters¶
path string
text string