| author | |
| committer | |
| log | 83e4ff6f4c739096806b951e7c6e54399c18d19b |
| tree | d2226d860751bbb682077a2b96aac5856e9e4ad0 |
| parent | 21e195a1a96100cd5bcd47b6d9565b2141ad13e1 |
4 files changed, 14 insertions(+), 9 deletions(-)
lib/std/Io.zig+1| ... | ... | @@ -667,6 +667,7 @@ pub const VTable = struct { |
| 667 | 667 | dirCreateFile: *const fn (?*anyopaque, Dir, sub_path: []const u8, File.CreateFlags) File.OpenError!File, |
| 668 | 668 | dirOpenFile: *const fn (?*anyopaque, Dir, sub_path: []const u8, File.OpenFlags) File.OpenError!File, |
| 669 | 669 | dirOpenDir: *const fn (?*anyopaque, Dir, sub_path: []const u8, Dir.OpenOptions) Dir.OpenError!Dir, |
| 670 | dirClose: *const fn (?*anyopaque, Dir) void, | |
| 670 | 671 | fileStat: *const fn (?*anyopaque, File) File.StatError!File.Stat, |
| 671 | 672 | fileClose: *const fn (?*anyopaque, File) void, |
| 672 | 673 | fileWriteStreaming: *const fn (?*anyopaque, File, buffer: [][]const u8) File.WriteStreamingError!usize, |
lib/std/Io/Dir.zig+4| ... | ... | @@ -93,6 +93,10 @@ pub fn openDir(dir: Dir, io: Io, sub_path: []const u8, options: OpenOptions) Ope |
| 93 | 93 | return io.vtable.dirOpenDir(io.userdata, dir, sub_path, options); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | pub fn close(dir: Dir, io: Io) void { | |
| 97 | return io.vtable.dirClose(io.userdata, dir); | |
| 98 | } | |
| 99 | ||
| 96 | 100 | pub fn openFile(dir: Dir, io: Io, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File { |
| 97 | 101 | return io.vtable.dirOpenFile(io.userdata, dir, sub_path, flags); |
| 98 | 102 | } |
lib/std/Io/Threaded.zig+7| ... | ... | @@ -203,6 +203,7 @@ pub fn io(t: *Threaded) Io { |
| 203 | 203 | .wasi => dirOpenDirWasi, |
| 204 | 204 | else => dirOpenDirPosix, |
| 205 | 205 | }, |
| 206 | .dirClose = dirClose, | |
| 206 | 207 | .fileClose = fileClose, |
| 207 | 208 | .fileWriteStreaming = fileWriteStreaming, |
| 208 | 209 | .fileWritePositional = fileWritePositional, |
| ... | ... | @@ -1685,6 +1686,12 @@ fn dirOpenDirPosix( |
| 1685 | 1686 | @panic("TODO"); |
| 1686 | 1687 | } |
| 1687 | 1688 | |
| 1689 | fn dirClose(userdata: ?*anyopaque, dir: Io.Dir) void { | |
| 1690 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | |
| 1691 | _ = t; | |
| 1692 | posix.close(dir.handle); | |
| 1693 | } | |
| 1694 | ||
| 1688 | 1695 | fn dirOpenDirWasi( |
| 1689 | 1696 | userdata: ?*anyopaque, |
| 1690 | 1697 | dir: Io.Dir, |
lib/std/Io/net.zig+2-9| ... | ... | @@ -1033,9 +1033,8 @@ pub const Socket = struct { |
| 1033 | 1033 | }; |
| 1034 | 1034 | |
| 1035 | 1035 | /// Leaves `address` in a valid state. |
| 1036 | pub fn close(s: *Socket, io: Io) void { | |
| 1036 | pub fn close(s: *const Socket, io: Io) void { | |
| 1037 | 1037 | io.vtable.netClose(io.userdata, s.handle); |
| 1038 | s.handle = undefined; | |
| 1039 | 1038 | } |
| 1040 | 1039 | |
| 1041 | 1040 | pub const SendError = error{ |
| ... | ... | @@ -1163,13 +1162,7 @@ pub const Stream = struct { |
| 1163 | 1162 | |
| 1164 | 1163 | const max_iovecs_len = 8; |
| 1165 | 1164 | |
| 1166 | pub fn close(s: *Stream, io: Io) void { | |
| 1167 | io.vtable.netClose(io.userdata, s.socket.handle); | |
| 1168 | s.* = undefined; | |
| 1169 | } | |
| 1170 | ||
| 1171 | /// Same as `close` but doesn't try to set `Stream` to `undefined`. | |
| 1172 | pub fn closeConst(s: *const Stream, io: Io) void { | |
| 1165 | pub fn close(s: *const Stream, io: Io) void { | |
| 1173 | 1166 | io.vtable.netClose(io.userdata, s.socket.handle); |
| 1174 | 1167 | } |
| 1175 | 1168 |