Skip to content

PlatformAPI reference

Class FolderContentSource

Namespace: MicroEngine.Platform
Assembly: MicroEngine.Platform.dll
Guide: The platform host

Content files in a folder on disk. Names must match the files’ letter case exactly on every system: “Hero.png” for “hero.png” works on Windows and macOS but not on Linux, Android or in browsers, so it fails everywhere, naming the real spelling. Paths that leave the folder (.., another drive) are refused.

C#
public sealed class FolderContentSource : IContentSource

Inheritance

object ← FolderContentSource

Implements

IContentSource

Remarks

Safe to read from several threads (asset workers check names concurrently).

Constructors

FolderContentSource(string)

Opens a folder.

C#
public FolderContentSource(string root)

Parameters

root string

The folder, absolute or relative to the working directory.

Exceptions

ArgumentException

root is null, empty or white space.

DirectoryNotFoundException

The folder does not exist.

Properties

Location

The same as Root.

C#
public string Location { get; }

Property Value

string

Root

The absolute path of the folder.

C#
public string Root { get; }

Property Value

string

Methods

Exists(string)

Whether a file exists at path. False for a missing file and for a path outside the source.

C#
public bool Exists(string path)

Parameters

path string

Returns

bool

Files(string)

The files directly inside folder (“” for the top), as paths relative to the source, in ordinal order.

C#
public IReadOnlyList<string> Files(string folder)

Parameters

folder string

Returns

IReadOnlyList<string>

Exceptions

DirectoryNotFoundException

The folder does not exist.

Open(string)

Opens the file at path for reading; the caller disposes the stream.

C#
public Stream Open(string path)

Parameters

path string

Returns

Stream

Exceptions

ArgumentException

The path leaves the source.

FileNotFoundException

No such file, or its name is spelled with another letter case.

PathOf(string)

The full path of the file at path, after the checks of Open.

C#
public string PathOf(string path)

Parameters

path string

Returns

string

Exceptions

ArgumentException

The path leaves the folder.

FileNotFoundException

No such file, or its name is spelled with another letter case.