| ... | ... | @@ -23,11 +23,25 @@ pub fn close(self: File) void { |
| 23 | 23 | sys_linux.close(@intFromEnum(self.fd)) catch {}; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | const R = nio.Readable(@This(), ._bare); |
| 27 | pub const readAll = R.readAll; |
| 28 | pub const readAtLeast = R.readAtLeast; |
| 29 | pub const readNoEof = R.readNoEof; |
| 30 | pub const readAllAlloc = R.readAllAlloc; |
| 31 | pub const readArray = R.readArray; |
| 32 | pub const readByte = R.readByte; |
| 33 | pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList; |
| 34 | pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc; |
| 35 | pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf; |
| 36 | pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList; |
| 37 | pub const readAlloc = R.readAlloc; |
| 38 | pub const readInt = R.readInt; |
| 39 | pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc; |
| 40 | |
| 26 | 41 | pub const ReadError = switch (builtin.target.os.tag) { |
| 27 | 42 | .linux => sys_linux.errno.Error, |
| 28 | 43 | else => @compileError("TODO"), |
| 29 | 44 | }; |
| 30 | | pub usingnamespace nio.Readable(@This(), ._bare); |
| 31 | 45 | pub fn read(self: File, buffer: []u8) ReadError!usize { |
| 32 | 46 | if (os == .linux) |
| 33 | 47 | return sys_linux.read(@intFromEnum(self.fd), buffer); |
| ... | ... | @@ -89,8 +103,17 @@ pub fn readAllArrayList(self: File, array_list: *std.ArrayList(u8), max_append_s |
| 89 | 103 | } |
| 90 | 104 | } |
| 91 | 105 | |
| 106 | const W = nio.Writable(@This(), ._bare); |
| 107 | pub const writeAll = W.writeAll; |
| 108 | pub const writevAll = W.writevAll; |
| 109 | pub const writeByteNTimes = W.writeByteNTimes; |
| 110 | pub const writeNTimes = W.writeNTimes; |
| 111 | pub const writeInt = W.writeInt; |
| 112 | pub const writeStruct = W.writeStruct; |
| 113 | pub const writeIntPretty = W.writeIntPretty; |
| 114 | pub const print = W.print; |
| 115 | |
| 92 | 116 | pub const WriteError = sys.errno.Error; |
| 93 | | pub usingnamespace nio.Writable(@This(), ._bare); |
| 94 | 117 | pub fn write(self: File, buffer: []const u8) WriteError!usize { |
| 95 | 118 | return sys.write(@intFromEnum(self.fd), buffer); |
| 96 | 119 | } |