Class SaveData

Represents a "save data store".

Hierarchy

  • SaveData

Constructors

  • Creates a new SaveData instance with manually provided values.

    Parameters

    • spaceId: number
    • id: bigint

    Returns SaveData

    Note

    This does not create new save data - the values should represent an existing save data.

  • Parameters

    Returns SaveData

Properties

applicationId: bigint
id: bigint
index: number
rank: number
size: bigint
spaceId: number
systemId: bigint
type: number
url: null | URL

A URL instance that points to the root of the filesystem mount. You should use this to create file path references within the filesystem mount.

Example

const dataUrl = new URL('data.json', saveData.url);

Methods

  • Commits to the disk any write operations that have occurred on this filesystem mount since the previous commit.

    Failure to call this function after writes will cause the data to be lost after the application exits.

    Returns void

    Example

    const saveStateUrl = new URL('state', saveData.url);
    Switch.writeFileSync(saveStateUrl, 'my application state...');

    saveData.commit(); // Write operation is persisted to the disk
  • Returns void

  • Parameters

    • dataSize: bigint
    • journalSize: bigint

    Returns void

  • Mounts the save data such that filesystem operations may be used.

    Parameters

    • name: string = ...

      The name of the mount for filesystem paths. By default, a random name is generated. Shouldn't exceed 31 characters, and shouldn't have a trailing colon.

    Returns URL

  • Unmounts the filesystem mount. Any filesytem operations attempting to use the mount path in the future will throw an error.

    Returns void

    Example

    Switch.readFileSync(device.url); // OK

    device.unmount();

    Switch.readFileSync(device.url); // ERROR THROWN!
  • Parameters

    Returns undefined | SaveData

Generated using TypeDoc