SplitScript reference / File / readAllBytes

File.readAllBytes

Function

File.readAllBytes(path: String) -> [u8]!

Reads an entire file as raw bytes.

The file is opened read-only and closed before this function returns. An empty file produces an empty array. Missing files, directories, inaccessible paths, and interrupted reads return an error. Repeated calls always consult the filesystem and are not cached.

Parameters

  • path: Absolute path in the portable WASI namespace. The host filesystem is currently below /mnt: C:\Games\data.bin maps to /mnt/c/Games/data.bin, while /opt/game/data.bin maps to /mnt/opt/game/data.bin.

Effects: allocates, reads the filesystem

Runtime behavior: available everywhere; synchronous

Examples

Load a binary lookup table

let table = File.readAllBytes("/mnt/c/Games/example/tables/rooms.bin")?