Skip to content

Files

The plugin’s own files, whole at a time, like its saves and cache. Each call runs on a worker, so it never stalls a game thread, and the game’s I/O watchers don’t see it. Any thread.

A path is relative to a root, or absolute. Its own folders (game_data, data, cache) are free to read and write, and its own files and the game’s folder free to read. So is whatever the player picks in pickFile or pickFolder. Anything else needs “files”: true in “permissions” in its wraith.json.

Get it with Api.files().

resolve(root: Wraith.Files.Root | Wraith.Files.RootName, path: string): string
read(root: Wraith.Files.Root | Wraith.Files.RootName, path: string, max_bytes: number | bigint): Promise<Uint8Array | null>
write(root: Wraith.Files.Root | Wraith.Files.RootName, path: string, bytes: Array<number>): Promise<void>
append(root: Wraith.Files.Root | Wraith.Files.RootName, path: string, bytes: Array<number>): Promise<void>
list(root: Wraith.Files.Root | Wraith.Files.RootName, path: string): Promise<Array<Wraith.Files.Info>>
stat(root: Wraith.Files.Root | Wraith.Files.RootName, path: string): Promise<Wraith.Files.Info>
remove(root: Wraith.Files.Root | Wraith.Files.RootName, path: string): Promise<void>
move(from_root: Wraith.Files.Root | Wraith.Files.RootName, from: string, to_root: Wraith.Files.Root | Wraith.Files.RootName, to: string): Promise<void>
makeDir(root: Wraith.Files.Root | Wraith.Files.RootName, path: string): Promise<void>
pickFile(options: import("salamander").Given<Wraith.Files.FileDialog>): Promise<string | null>
pickFolder(options: import("salamander").Given<Wraith.Files.FolderDialog>): Promise<string | null>

The full path, or path itself when it’s absolute. For showing the player, not for opening yourself.

Fails with FileError. Uses Files.Root.

Its whole contents, up to max_bytes, or 64 MiB when 0.

Async. Fails with FileError. Uses Files.Root.

Replaces it whole, through a temporary file so it’s never left half written. Makes its folders.

Async. Fails with FileError. Uses Files.Root.

Onto the end, making it if it isn’t there.

Async. Fails with FileError. Uses Files.Root.

What’s in a folder, not in any order.

Async. Fails with FileError. Uses Files.Root, Files.Info.

Async. Fails with FileError. Uses Files.Root, Files.Info.

A file, or an empty folder.

Async. Fails with FileError. Uses Files.Root.

A file or folder, within one drive. Makes to’s folders.

Async. Fails with FileError. Uses Files.Root.

And the folders it’s in. Fine if it’s there already.

Async. Fails with FileError. Uses Files.Root.

Windows’ own dialogs. The full path, or null if cancelled. Till the plugin unloads it may read what the player picked to open, read and write what they picked to save, and use anything in a folder they picked, whatever its “permissions” say.

Async. Fails with FileError. Uses Files.FileDialog.

Async. Fails with FileError. Uses Files.FolderDialog.

What can go wrong, besides Cancelled, Unsupported and Gone.

Code Error
1 NotFound
2 Exists Something’s already where move would put it
3 Denied The system refused, like a read-only file or one another program has open
4 NotDeclared Outside its own folders, and its wraith.json doesn’t list “files” in “permissions”
5 WrongKind A folder where a file should be, or the other way around
6 NotEmpty A folder with something in it, for remove
7 TooBig Bigger than read was allowed
8 InvalidPath Empty, or a relative path that leaves its root
9 Failed

An enum of u8.

Value Name
0 game_data Its data for this game, kept across updates
1 data Its data for every game, like its settings
2 cache Safe to delete, like downloads
3 plugin Its own files, as installed. Read only
4 game The game’s folder. Read only without “files”

A struct, 0x58 bytes, aligned to 8.

Offset Field Type
0x0 save bool Where to write one, else one to open
0x8 title string
0x18 folder string Where it starts. Empty is the system’s pick
0x28 file_name string Filled in to start with, for saving
0x38 kind string Like “Pose”
0x48 extension string Like “.pose”, added when a name’s typed without it
save: boolean
title: string
folder: string
file_name: string
kind: string
extension: string

A struct, 0x20 bytes, aligned to 8.

Offset Field Type
0x0 title string
0x10 folder string
title: string
folder: string

A struct, 0x28 bytes, aligned to 8.

Offset Field Type
0x0 name string
0x10 directory bool
0x18 size u64
0x20 modified_ms i64 Milliseconds since 1970
name: string
directory: boolean
size: bigint
modified_ms: bigint

Made with ♥ by Asgard