Skip to content

KernelAPI reference

Class FileSaveStorage

Namespace: MicroEngine.Core
Assembly: MicroEngine.Saves.dll
Guide: Saving data

One JSON file per slot in a directory (desktop and tests).

C#
public sealed class FileSaveStorage : ISaveStorage, IStorage

Inheritance

object ← FileSaveStorage

Implements

ISaveStorage, IStorage

Constructors

FileSaveStorage(string)

One JSON file per slot in a directory (desktop and tests).

C#
public FileSaveStorage(string directory)

Parameters

directory string

Properties

Location

The directory that holds the slot files.

C#
public string Location { get; }

Property Value

string

Methods

Delete(string)

Removes the slot; does nothing when it does not exist.

C#
public void Delete(string slot)

Parameters

slot string

Exists(string)

Whether the slot has data.

C#
public bool Exists(string slot)

Parameters

slot string

Returns

bool

Read(string)

The slot’s text, or null when it does not exist.

C#
public string? Read(string slot)

Parameters

slot string

Returns

string?

SetAside(string)

Renames <slot>.json to <slot>.corrupt.json, replacing an earlier copy; leaves the file in place if that fails.

C#
public void SetAside(string slot)

Parameters

slot string

Write(string, string)

Writes atomically (temp file + move).

C#
public void Write(string slot, string text)

Parameters

slot string

text string