KernelAPI reference
Class ContentFolder
Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Assets
Locates a game’s asset files. By default the root is the Content folder next to the
executable (games copy it there at build time). Missing files fail with the full path so a
broken install or a typo is obvious. A content source (IContentSource) over a
FolderContentSource.
public sealed class ContentFolder : IContentSourceInheritance
Implements
Constructors
ContentFolder(string?)
Opens a content folder.
public ContentFolder(string? root = null)Parameters
root string?
The folder, absolute or relative to the working directory; null uses the Content folder next to the executable. A host whose files live elsewhere (a phone app, a macOS bundle) composes its folder instead (Content).
Exceptions
The folder does not exist.
Properties
DefaultRoot
The folder used when a game and its composition name none: Content next to the executable. A rule, not a
setting: a host whose files live elsewhere (a phone app, a macOS bundle) composes its folder
(Content).
public static string DefaultRoot { get; }Property Value
Location
The same as Root.
public string Location { get; }Property Value
Root
The absolute path of the content folder.
public string Root { get; }Property Value
Methods
Exists(string)
Whether a file exists at relative (relative to Root, ‘/’ separators). False for a missing file and for a path outside the folder.
public bool Exists(string relative)Parameters
relative string
Returns
Files(string)
The files directly inside folder (relative to the root, ‘/’ separators; “” for the root), as
‘/’-separated paths relative to the root, in ordinal order.
public IReadOnlyList<string> Files(string folder)Parameters
folder string
Returns
Exceptions
The folder does not exist.
Image(string)
Decodes a PNG file into an image (see Load).
public PixelImage Image(string relative)Parameters
relative string
Returns
Exceptions
The file does not exist.
Open(string)
Opens a file for reading, after the checks of PathOf.
public Stream Open(string relative)Parameters
relative string
Returns
PathOf(string)
Full path of a file given relative to the root with ‘/’ separators. The name must match the file’s 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 file’s real spelling.
public string PathOf(string relative)Parameters
relative string
Returns
Exceptions
The path leaves the content folder.
No such file, or its name is spelled with another letter case.
ReadBytes(string)
Reads a whole file.
public byte[] ReadBytes(string relative)Parameters
relative string
Returns
byte[]
Exceptions
The file does not exist.