| ... | ... | @@ -10,6 +10,11 @@ const File = @This(); |
| 10 | 10 | |
| 11 | 11 | const os = builtin.target.os.tag; |
| 12 | 12 | |
| 13 | const sys = switch (os) { |
| 14 | .linux => sys_linux, |
| 15 | else => unreachable, |
| 16 | }; |
| 17 | |
| 13 | 18 | fd: nfs.Handle, |
| 14 | 19 | |
| 15 | 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 | 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 | 98 | pub const Stat = struct { |
| 88 | 99 | inode: INode, |
| 89 | 100 | size: u64, |
| ... | ... | @@ -137,14 +148,12 @@ pub const Stat = struct { |
| 137 | 148 | }; |
| 138 | 149 | |
| 139 | 150 | pub const INode = switch (builtin.target.os.tag) { |
| 140 | | .linux, |
| 141 | | => sys_linux.ino_t, |
| 151 | .linux => sys_linux.ino_t, |
| 142 | 152 | else => |v| @compileError("TODO: " ++ @tagName(v)), |
| 143 | 153 | }; |
| 144 | 154 | |
| 145 | 155 | pub const Mode = switch (builtin.target.os.tag) { |
| 146 | | .linux, |
| 147 | | => sys_linux.mode_t, |
| 156 | .linux => sys_linux.mode_t, |
| 148 | 157 | else => |v| @compileError("TODO: " ++ @tagName(v)), |
| 149 | 158 | }; |
| 150 | 159 | |