diff options
Diffstat (limited to 'src/abi.zig')
| -rw-r--r-- | src/abi.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/abi.zig b/src/abi.zig index aecb654..3991a35 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -647,8 +647,8 @@ pub const Host = struct { samples: *const fn (*anyopaque, Audio) []const f32, /// The whole file, mapped for the life of the host; empty if missing. readFile: *const fn (*anyopaque, []const u8) []const u8, - /// See `Host.appendFile`: name, then bytes. - appendFile: *const fn (*anyopaque, [*]const u8, usize, [*]const u8, usize) callconv(.c) [*:0]const u8, + /// See `Host.appendFile`: name, then bytes; `replace` for `writeFile`. + appendFile: *const fn (*anyopaque, [*]const u8, usize, [*]const u8, usize, bool) callconv(.c) [*:0]const u8, env:*const fn (*anyopaque, []const u8) ?[]const u8, /// A monotonic clock in nanoseconds, for measuring, not for state: /// `update` must use `Input` time to stay replayable. @@ -730,7 +730,12 @@ pub const Host = struct { /// replayed, like sound. `readFile` maps a file once: what is appended /// to it afterwards is not in what it returned. pub fn appendFile(h: Host, name: []const u8, bytes: []const u8) []const u8 { - return std.mem.span(h.vtable.appendFile(h.ctx, name.ptr, name.len, bytes.ptr, bytes.len)); + return std.mem.span(h.vtable.appendFile(h.ctx, name.ptr, name.len, bytes.ptr, bytes.len, false)); + } + /// `appendFile` to a new, empty file of that name: what the old one + /// held is gone (a `readFile` of it keeps its bytes). + pub fn writeFile(h: Host, name: []const u8, bytes: []const u8) []const u8 { + return std.mem.span(h.vtable.appendFile(h.ctx, name.ptr, name.len, bytes.ptr, bytes.len, true)); } pub fn env(h: Host, name: []const u8) ?[]const u8 { return h.vtable.env(h.ctx, name); |
