Skip to content

Class VfsPath

Namespace: Apogee.Content.FileSystem
Assembly: Apogee.Content.dll

Paths of the virtual file system: scheme://a/b/c.txt, always with /, case-sensitive. is strict, for the paths a program or a script names: no . or .. segments, no empty ones, nothing a Windows file system would treat differently (a trailing dot or space, device names, :, wildcards), so that a path means the same on every platform and cannot leave its mount. and are lenient, for resolving a path a file refers to (a texture next to a model, a require("../x")): .. climbs but stops at the root of the scheme. They work on plain paths too.

public static class VfsPath

Inheritance

object ← VfsPath

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods

Combine(string, string)

relative as seen from directory: a path with a scheme stands for itself, a leading slash is the root of the directory's scheme. Not normalized.

public static string Combine(string directory, string relative)

Parameters

directory string

relative string

Returns

string

DirectoryOf(string)

The folder of a path: res://a/b.txt gives res://a, and res://b.txt gives the root res://.

public static string DirectoryOf(string path)

Parameters

path string

Returns

string

FileName(string)

The last segment.

public static string FileName(string path)

Parameters

path string

Returns

string

IsUnder(string, string)

True when path is directory or inside it. Both canonical or normalized.

public static bool IsUnder(string path, string directory)

Parameters

path string

directory string

Returns

bool

IsValidSegment(string, out string?)

True when name can be one segment of a path on every platform.

public static bool IsValidSegment(string name, out string? problem)

Parameters

name string

problem string?

Returns

bool

IsVirtual(string)

True for scheme://…: a lowercase scheme of letters, digits and underscores that starts with a letter, so a Windows drive (C:/) is not one.

public static bool IsVirtual(string path)

Parameters

path string

Returns

bool

Normalize(string)

Forward slashes, no . or .. segments (a .. at the root is dropped), no trailing slash. Keeps a scheme or a leading slash.

public static string Normalize(string path)

Parameters

path string

Returns

string

ParentOf(string)

The folder above a folder, or null at the root.

public static string? ParentOf(string directory)

Parameters

directory string

Returns

string?

Parse(string)

The canonical form of path: its scheme, then its segments, with no trailing slash (the root of a scheme is res://).

public static string Parse(string path)

Parameters

path string

Returns

string

Exceptions

VfsException

The path is not a valid virtual path.

TryParse(string, out string, out string?)

public static bool TryParse(string path, out string canonical, out string? problem)

Parameters

path string

canonical string

problem string?

Returns

bool

TrySplit(string, out string, out string)

Splits scheme://rest into scheme and rest.

public static bool TrySplit(string path, out string scheme, out string rest)

Parameters

path string

scheme string

rest string

Returns

bool