Esc

write_file

procedureextensionexperimental2 overloadssince 0.36.1Source
  • macOS: write_file works on macOS
  • Linux: write_file works on Linux
  • Windows: write_file works on Windows
  • Wasm: write_file is not available on Wasm

overload 1

write_file :: (w: *Writer, path: string, data: string) -> bool

Writes an asset, which also counts as a link target. Returns false and collects any error.

Example
w := writer_init("unused", "/", true);
defer deinit(*w);
assert(write_file(*w, "assets/a.js", "let a = 1;"));

overload 2

write_file :: (w: *Writer, path: string, data: [] u8) -> bool

Writes a byte slice as an asset.

Example
w := writer_init("unused", "/", true);
defer deinit(*w);
data := u8.[1, 2, 3];
assert(write_file(*w, "data.bin", data));

See also