| ... | @@ -10,6 +10,11 @@ const File = @This(); | ... | @@ -10,6 +10,11 @@ const File = @This(); |
| 10 | | 10 | |
| 11 | const os = builtin.target.os.tag; | 11 | const os = builtin.target.os.tag; |
| 12 | | 12 | |
| | 13 | const sys = switch (os) { |
| | 14 | .linux => sys_linux, |
| | 15 | else => unreachable, |
| | 16 | }; |
| | 17 | |
| 13 | fd: nfs.Handle, | 18 | fd: nfs.Handle, |
| 14 | | 19 | |
| 15 | // Resource allocation may fail; resource deallocation must succeed. | 20 | // 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 | ... | @@ -84,6 +89,12 @@ pub fn readAllArrayList(self: File, array_list: *std.ArrayList(u8), max_append_s |
| 84 | } | 89 | } |
| 85 | } | 90 | } |
| 86 | | 91 | |
| | 92 | pub const WriteError = sys.errno.Error; |
| | 93 | pub usingnamespace nio.Writable(@This(), ._bare); |
| | 94 | pub fn write(self: File, buffer: []const u8) WriteError!usize { |
| | 95 | return sys.write(@intFromEnum(self.fd), buffer); |
| | 96 | } |
| | 97 | |
| 87 | pub const Stat = struct { | 98 | pub const Stat = struct { |
| 88 | inode: INode, | 99 | inode: INode, |
| 89 | size: u64, | 100 | size: u64, |
| ... | @@ -137,14 +148,12 @@ pub const Stat = struct { | ... | @@ -137,14 +148,12 @@ pub const Stat = struct { |
| 137 | }; | 148 | }; |
| 138 | | 149 | |
| 139 | pub const INode = switch (builtin.target.os.tag) { | 150 | pub const INode = switch (builtin.target.os.tag) { |
| 140 | .linux, | 151 | .linux => sys_linux.ino_t, |
| 141 | => sys_linux.ino_t, | | |
| 142 | else => |v| @compileError("TODO: " ++ @tagName(v)), | 152 | else => |v| @compileError("TODO: " ++ @tagName(v)), |
| 143 | }; | 153 | }; |
| 144 | | 154 | |
| 145 | pub const Mode = switch (builtin.target.os.tag) { | 155 | pub const Mode = switch (builtin.target.os.tag) { |
| 146 | .linux, | 156 | .linux => sys_linux.mode_t, |
| 147 | => sys_linux.mode_t, | | |
| 148 | else => |v| @compileError("TODO: " ++ @tagName(v)), | 157 | else => |v| @compileError("TODO: " ++ @tagName(v)), |
| 149 | }; | 158 | }; |
| 150 | | 159 | |