Class SaveData

Represents a "save data store".

Hierarchy

  • SaveData

Constructors

  • Private

    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
  • Deletes the save data store.

    Returns void

    Warn

    This is a destructive operation! Use caution when using this function to avoid accidental data loss.

  • Grows a save data store to the requested dataSize and journalSize.

    Parameters

    • dataSize: bigint
    • journalSize: bigint

    Returns void

  • Returns bigint

  • 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

  • Returns bigint

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

    Returns void

    Example

    Switch.readDirSync(saveData.url); // OK

    saveData.unmount();

    Switch.readDirSync(saveData.url); // ERROR THROWN!
  • Parameters

    Returns undefined | SaveData

Generated using TypeDoc