authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:44:31 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:44:31 -08:00
logbe2fd8e7a40a739325faba750c606ecb8f779c00
treea135ac22fd4cbffd011aa127394a9e56cb61f738
parent277cdf3e84c90e0f8860c9514f7609816b352a7a

make File Writable


1 files changed, 13 insertions(+), 4 deletions(-)

File.zig+13-4
......@@ -10,6 +10,11 @@ const File = @This();
1010
1111const os = builtin.target.os.tag;
1212
13const sys = switch (os) {
14 .linux => sys_linux,
15 else => unreachable,
16};
17
1318fd: nfs.Handle,
1419
1520// Resource allocation may fail; resource deallocation must succeed.
......@@ -84,6 +89,12 @@ pub fn readAllArrayList(self: File, array_list: *std.ArrayList(u8), max_append_s
8489 }
8590}
8691
92pub const WriteError = sys.errno.Error;
93pub usingnamespace nio.Writable(@This(), ._bare);
94pub fn write(self: File, buffer: []const u8) WriteError!usize {
95 return sys.write(@intFromEnum(self.fd), buffer);
96}
97
8798pub const Stat = struct {
8899 inode: INode,
89100 size: u64,
......@@ -137,14 +148,12 @@ pub const Stat = struct {
137148};
138149
139150pub const INode = switch (builtin.target.os.tag) {
140 .linux,
141 => sys_linux.ino_t,
151 .linux => sys_linux.ino_t,
142152 else => |v| @compileError("TODO: " ++ @tagName(v)),
143153};
144154
145155pub const Mode = switch (builtin.target.os.tag) {
146 .linux,
147 => sys_linux.mode_t,
156 .linux => sys_linux.mode_t,
148157 else => |v| @compileError("TODO: " ++ @tagName(v)),
149158};
150159