authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-05 17:46:35-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:07-08:00
logeab354b2f5d7242c036523394023e9824be7eca9
tree1234b3042bcc5483e106eb649136187c6d31ddbd
parent72b76077ab4e5042b13ea311063f2c7e867e00ba

std.Io.Threaded: import File and Dir


1 files changed, 165 insertions(+), 163 deletions(-)

lib/std/Io/Threaded.zig+165-163
......@@ -11,6 +11,8 @@ const is_debug = builtin.mode == .Debug;
1111const std = @import("../std.zig");
1212const Io = std.Io;
1313const net = std.Io.net;
14const File = std.Io.File;
15const Dir = std.Dir;
1416const HostName = std.Io.net.HostName;
1517const IpAddress = std.Io.net.IpAddress;
1618const Allocator = std.mem.Allocator;
......@@ -1444,7 +1446,7 @@ const dirMake = switch (native_os) {
14441446 else => dirMakePosix,
14451447};
14461448
1447fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void {
1449fn dirMakePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void {
14481450 const t: *Threaded = @ptrCast(@alignCast(userdata));
14491451 const current_thread = Thread.getCurrent(t);
14501452
......@@ -1490,7 +1492,7 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode:
14901492 }
14911493}
14921494
1493fn dirMakeWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void {
1495fn dirMakeWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void {
14941496 if (builtin.link_libc) return dirMakePosix(userdata, dir, sub_path, mode);
14951497 const t: *Threaded = @ptrCast(@alignCast(userdata));
14961498 const current_thread = Thread.getCurrent(t);
......@@ -1532,7 +1534,7 @@ fn dirMakeWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: I
15321534 }
15331535}
15341536
1535fn dirMakeWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void {
1537fn dirMakeWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void {
15361538 const t: *Threaded = @ptrCast(@alignCast(userdata));
15371539 const current_thread = Thread.getCurrent(t);
15381540 try current_thread.checkCancel();
......@@ -1560,14 +1562,14 @@ fn dirMakeWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode
15601562
15611563fn dirMakePath(
15621564 userdata: ?*anyopaque,
1563 dir: Io.Dir,
1565 dir: Dir,
15641566 sub_path: []const u8,
1565 mode: Io.Dir.Mode,
1566) Io.Dir.MakePathError!Io.Dir.MakePathStatus {
1567 mode: Dir.Mode,
1568) Dir.MakePathError!Dir.MakePathStatus {
15671569 const t: *Threaded = @ptrCast(@alignCast(userdata));
15681570
15691571 var it = std.fs.path.componentIterator(sub_path);
1570 var status: Io.Dir.MakePathStatus = .existed;
1572 var status: Dir.MakePathStatus = .existed;
15711573 var component = it.last() orelse return error.BadPathName;
15721574 while (true) {
15731575 if (dirMake(t, dir, component.path, mode)) |_| {
......@@ -1604,10 +1606,10 @@ const dirMakeOpenPath = switch (native_os) {
16041606
16051607fn dirMakeOpenPathPosix(
16061608 userdata: ?*anyopaque,
1607 dir: Io.Dir,
1609 dir: Dir,
16081610 sub_path: []const u8,
1609 options: Io.Dir.OpenOptions,
1610) Io.Dir.MakeOpenPathError!Io.Dir {
1611 options: Dir.OpenOptions,
1612) Dir.MakeOpenPathError!Dir {
16111613 const t: *Threaded = @ptrCast(@alignCast(userdata));
16121614 const t_io = ioBasic(t);
16131615 return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) {
......@@ -1621,10 +1623,10 @@ fn dirMakeOpenPathPosix(
16211623
16221624fn dirMakeOpenPathWindows(
16231625 userdata: ?*anyopaque,
1624 dir: Io.Dir,
1626 dir: Dir,
16251627 sub_path: []const u8,
1626 options: Io.Dir.OpenOptions,
1627) Io.Dir.MakeOpenPathError!Io.Dir {
1628 options: Dir.OpenOptions,
1629) Dir.MakeOpenPathError!Dir {
16281630 const t: *Threaded = @ptrCast(@alignCast(userdata));
16291631 const current_thread = Thread.getCurrent(t);
16301632 const w = windows;
......@@ -1644,7 +1646,7 @@ fn dirMakeOpenPathWindows(
16441646 const is_last = it.peekNext() == null;
16451647 const create_disposition: w.FILE.CREATE_DISPOSITION = if (is_last) .OPEN_IF else .CREATE;
16461648
1647 var result: Io.Dir = .{ .handle = undefined };
1649 var result: Dir = .{ .handle = undefined };
16481650
16491651 const path_len_bytes: u16 = @intCast(sub_path_w.len * 2);
16501652 var nt_name: w.UNICODE_STRING = .{
......@@ -1736,10 +1738,10 @@ fn dirMakeOpenPathWindows(
17361738
17371739fn dirMakeOpenPathWasi(
17381740 userdata: ?*anyopaque,
1739 dir: Io.Dir,
1741 dir: Dir,
17401742 sub_path: []const u8,
1741 options: Io.Dir.OpenOptions,
1742) Io.Dir.MakeOpenPathError!Io.Dir {
1743 options: Dir.OpenOptions,
1744) Dir.MakeOpenPathError!Dir {
17431745 const t: *Threaded = @ptrCast(@alignCast(userdata));
17441746 const t_io = ioBasic(t);
17451747 return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) {
......@@ -1751,9 +1753,9 @@ fn dirMakeOpenPathWasi(
17511753 };
17521754}
17531755
1754fn dirStat(userdata: ?*anyopaque, dir: Io.Dir) Io.Dir.StatError!Io.Dir.Stat {
1756fn dirStat(userdata: ?*anyopaque, dir: Dir) Dir.StatError!Dir.Stat {
17551757 const t: *Threaded = @ptrCast(@alignCast(userdata));
1756 const file: Io.File = .{ .handle = dir.handle };
1758 const file: File = .{ .handle = dir.handle };
17571759 return fileStat(t, file);
17581760}
17591761
......@@ -1766,10 +1768,10 @@ const dirStatPath = switch (native_os) {
17661768
17671769fn dirStatPathLinux(
17681770 userdata: ?*anyopaque,
1769 dir: Io.Dir,
1771 dir: Dir,
17701772 sub_path: []const u8,
1771 options: Io.Dir.StatPathOptions,
1772) Io.Dir.StatPathError!Io.File.Stat {
1773 options: Dir.StatPathOptions,
1774) Dir.StatPathError!File.Stat {
17731775 const t: *Threaded = @ptrCast(@alignCast(userdata));
17741776 const current_thread = Thread.getCurrent(t);
17751777 const linux = std.os.linux;
......@@ -1828,10 +1830,10 @@ fn dirStatPathLinux(
18281830
18291831fn dirStatPathPosix(
18301832 userdata: ?*anyopaque,
1831 dir: Io.Dir,
1833 dir: Dir,
18321834 sub_path: []const u8,
1833 options: Io.Dir.StatPathOptions,
1834) Io.Dir.StatPathError!Io.File.Stat {
1835 options: Dir.StatPathOptions,
1836) Dir.StatPathError!File.Stat {
18351837 const t: *Threaded = @ptrCast(@alignCast(userdata));
18361838 const current_thread = Thread.getCurrent(t);
18371839
......@@ -1876,10 +1878,10 @@ fn dirStatPathPosix(
18761878
18771879fn dirStatPathWindows(
18781880 userdata: ?*anyopaque,
1879 dir: Io.Dir,
1881 dir: Dir,
18801882 sub_path: []const u8,
1881 options: Io.Dir.StatPathOptions,
1882) Io.Dir.StatPathError!Io.File.Stat {
1883 options: Dir.StatPathOptions,
1884) Dir.StatPathError!File.Stat {
18831885 const t: *Threaded = @ptrCast(@alignCast(userdata));
18841886 const file = try dirOpenFileWindows(t, dir, sub_path, .{
18851887 .follow_symlinks = options.follow_symlinks,
......@@ -1890,10 +1892,10 @@ fn dirStatPathWindows(
18901892
18911893fn dirStatPathWasi(
18921894 userdata: ?*anyopaque,
1893 dir: Io.Dir,
1895 dir: Dir,
18941896 sub_path: []const u8,
1895 options: Io.Dir.StatPathOptions,
1896) Io.Dir.StatPathError!Io.File.Stat {
1897 options: Dir.StatPathOptions,
1898) Dir.StatPathError!File.Stat {
18971899 if (builtin.link_libc) return dirStatPathPosix(userdata, dir, sub_path, options);
18981900 const t: *Threaded = @ptrCast(@alignCast(userdata));
18991901 const current_thread = Thread.getCurrent(t);
......@@ -1941,7 +1943,7 @@ const fileStat = switch (native_os) {
19411943 else => fileStatPosix,
19421944};
19431945
1944fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat {
1946fn fileStatPosix(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
19451947 const t: *Threaded = @ptrCast(@alignCast(userdata));
19461948 const current_thread = Thread.getCurrent(t);
19471949
......@@ -1974,7 +1976,7 @@ fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File
19741976 }
19751977}
19761978
1977fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat {
1979fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
19781980 const t: *Threaded = @ptrCast(@alignCast(userdata));
19791981 const current_thread = Thread.getCurrent(t);
19801982 const linux = std.os.linux;
......@@ -2025,7 +2027,7 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File
20252027 }
20262028}
20272029
2028fn fileStatWindows(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat {
2030fn fileStatWindows(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
20292031 const t: *Threaded = @ptrCast(@alignCast(userdata));
20302032 const current_thread = Thread.getCurrent(t);
20312033 try current_thread.checkCancel();
......@@ -2071,7 +2073,7 @@ fn fileStatWindows(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.Fi
20712073 };
20722074}
20732075
2074fn fileStatWasi(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat {
2076fn fileStatWasi(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
20752077 if (builtin.link_libc) return fileStatPosix(userdata, file);
20762078
20772079 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -2113,10 +2115,10 @@ const dirAccess = switch (native_os) {
21132115
21142116fn dirAccessPosix(
21152117 userdata: ?*anyopaque,
2116 dir: Io.Dir,
2118 dir: Dir,
21172119 sub_path: []const u8,
2118 options: Io.Dir.AccessOptions,
2119) Io.Dir.AccessError!void {
2120 options: Dir.AccessOptions,
2121) Dir.AccessError!void {
21202122 const t: *Threaded = @ptrCast(@alignCast(userdata));
21212123 const current_thread = Thread.getCurrent(t);
21222124
......@@ -2167,10 +2169,10 @@ fn dirAccessPosix(
21672169
21682170fn dirAccessWasi(
21692171 userdata: ?*anyopaque,
2170 dir: Io.Dir,
2172 dir: Dir,
21712173 sub_path: []const u8,
2172 options: Io.Dir.AccessOptions,
2173) Io.Dir.AccessError!void {
2174 options: Dir.AccessOptions,
2175) Dir.AccessError!void {
21742176 if (builtin.link_libc) return dirAccessPosix(userdata, dir, sub_path, options);
21752177 const t: *Threaded = @ptrCast(@alignCast(userdata));
21762178 const current_thread = Thread.getCurrent(t);
......@@ -2240,10 +2242,10 @@ fn dirAccessWasi(
22402242
22412243fn dirAccessWindows(
22422244 userdata: ?*anyopaque,
2243 dir: Io.Dir,
2245 dir: Dir,
22442246 sub_path: []const u8,
2245 options: Io.Dir.AccessOptions,
2246) Io.Dir.AccessError!void {
2247 options: Dir.AccessOptions,
2248) Dir.AccessError!void {
22472249 const t: *Threaded = @ptrCast(@alignCast(userdata));
22482250 const current_thread = Thread.getCurrent(t);
22492251 try current_thread.checkCancel();
......@@ -2292,10 +2294,10 @@ const dirCreateFile = switch (native_os) {
22922294
22932295fn dirCreateFilePosix(
22942296 userdata: ?*anyopaque,
2295 dir: Io.Dir,
2297 dir: Dir,
22962298 sub_path: []const u8,
2297 flags: Io.File.CreateFlags,
2298) Io.File.OpenError!Io.File {
2299 flags: File.CreateFlags,
2300) File.OpenError!File {
22992301 const t: *Threaded = @ptrCast(@alignCast(userdata));
23002302 const current_thread = Thread.getCurrent(t);
23012303
......@@ -2455,10 +2457,10 @@ fn dirCreateFilePosix(
24552457
24562458fn dirCreateFileWindows(
24572459 userdata: ?*anyopaque,
2458 dir: Io.Dir,
2460 dir: Dir,
24592461 sub_path: []const u8,
2460 flags: Io.File.CreateFlags,
2461) Io.File.OpenError!Io.File {
2462 flags: File.CreateFlags,
2463) File.OpenError!File {
24622464 const w = windows;
24632465 const t: *Threaded = @ptrCast(@alignCast(userdata));
24642466 const current_thread = Thread.getCurrent(t);
......@@ -2509,10 +2511,10 @@ fn dirCreateFileWindows(
25092511
25102512fn dirCreateFileWasi(
25112513 userdata: ?*anyopaque,
2512 dir: Io.Dir,
2514 dir: Dir,
25132515 sub_path: []const u8,
2514 flags: Io.File.CreateFlags,
2515) Io.File.OpenError!Io.File {
2516 flags: File.CreateFlags,
2517) File.OpenError!File {
25162518 const t: *Threaded = @ptrCast(@alignCast(userdata));
25172519 const current_thread = Thread.getCurrent(t);
25182520 const wasi = std.os.wasi;
......@@ -2593,10 +2595,10 @@ const dirOpenFile = switch (native_os) {
25932595
25942596fn dirOpenFilePosix(
25952597 userdata: ?*anyopaque,
2596 dir: Io.Dir,
2598 dir: Dir,
25972599 sub_path: []const u8,
2598 flags: Io.File.OpenFlags,
2599) Io.File.OpenError!Io.File {
2600 flags: File.OpenFlags,
2601) File.OpenError!File {
26002602 const t: *Threaded = @ptrCast(@alignCast(userdata));
26012603 const current_thread = Thread.getCurrent(t);
26022604
......@@ -2765,10 +2767,10 @@ fn dirOpenFilePosix(
27652767
27662768fn dirOpenFileWindows(
27672769 userdata: ?*anyopaque,
2768 dir: Io.Dir,
2770 dir: Dir,
27692771 sub_path: []const u8,
2770 flags: Io.File.OpenFlags,
2771) Io.File.OpenError!Io.File {
2772 flags: File.OpenFlags,
2773) File.OpenError!File {
27722774 const t: *Threaded = @ptrCast(@alignCast(userdata));
27732775 const sub_path_w_array = try windows.sliceToPrefixedFileW(dir.handle, sub_path);
27742776 const sub_path_w = sub_path_w_array.span();
......@@ -2780,8 +2782,8 @@ pub fn dirOpenFileWtf16(
27802782 t: *Threaded,
27812783 dir_handle: ?windows.HANDLE,
27822784 sub_path_w: [:0]const u16,
2783 flags: Io.File.OpenFlags,
2784) Io.File.OpenError!Io.File {
2785 flags: File.OpenFlags,
2786) File.OpenError!File {
27852787 if (std.mem.eql(u16, sub_path_w, &.{'.'})) return error.IsDir;
27862788 if (std.mem.eql(u16, sub_path_w, &.{ '.', '.' })) return error.IsDir;
27872789 const path_len_bytes = std.math.cast(u16, sub_path_w.len * 2) orelse return error.NameTooLong;
......@@ -2904,10 +2906,10 @@ pub fn dirOpenFileWtf16(
29042906
29052907fn dirOpenFileWasi(
29062908 userdata: ?*anyopaque,
2907 dir: Io.Dir,
2909 dir: Dir,
29082910 sub_path: []const u8,
2909 flags: Io.File.OpenFlags,
2910) Io.File.OpenError!Io.File {
2911 flags: File.OpenFlags,
2912) File.OpenError!File {
29112913 if (builtin.link_libc) return dirOpenFilePosix(userdata, dir, sub_path, flags);
29122914 const t: *Threaded = @ptrCast(@alignCast(userdata));
29132915 const current_thread = Thread.getCurrent(t);
......@@ -2991,10 +2993,10 @@ const dirOpenDir = switch (native_os) {
29912993/// This function is also used for WASI when libc is linked.
29922994fn dirOpenDirPosix(
29932995 userdata: ?*anyopaque,
2994 dir: Io.Dir,
2996 dir: Dir,
29952997 sub_path: []const u8,
2996 options: Io.Dir.OpenOptions,
2997) Io.Dir.OpenError!Io.Dir {
2998 options: Dir.OpenOptions,
2999) Dir.OpenError!Dir {
29983000 const t: *Threaded = @ptrCast(@alignCast(userdata));
29993001
30003002 if (is_windows) {
......@@ -3065,10 +3067,10 @@ fn dirOpenDirPosix(
30653067
30663068fn dirOpenDirHaiku(
30673069 userdata: ?*anyopaque,
3068 dir: Io.Dir,
3070 dir: Dir,
30693071 sub_path: []const u8,
3070 options: Io.Dir.OpenOptions,
3071) Io.Dir.OpenError!Io.Dir {
3072 options: Dir.OpenOptions,
3073) Dir.OpenError!Dir {
30723074 const t: *Threaded = @ptrCast(@alignCast(userdata));
30733075 const current_thread = Thread.getCurrent(t);
30743076
......@@ -3116,10 +3118,10 @@ fn dirOpenDirHaiku(
31163118
31173119pub fn dirOpenDirWindows(
31183120 t: *Io.Threaded,
3119 dir: Io.Dir,
3121 dir: Dir,
31203122 sub_path_w: [:0]const u16,
3121 options: Io.Dir.OpenOptions,
3122) Io.Dir.OpenError!Io.Dir {
3123 options: Dir.OpenOptions,
3124) Dir.OpenError!Dir {
31233125 const current_thread = Thread.getCurrent(t);
31243126 const w = windows;
31253127
......@@ -3130,7 +3132,7 @@ pub fn dirOpenDirWindows(
31303132 .Buffer = @constCast(sub_path_w.ptr),
31313133 };
31323134 var io_status_block: w.IO_STATUS_BLOCK = undefined;
3133 var result: Io.Dir = .{ .handle = undefined };
3135 var result: Dir = .{ .handle = undefined };
31343136 try current_thread.checkCancel();
31353137 const rc = w.ntdll.NtCreateFile(
31363138 &result.handle,
......@@ -3190,7 +3192,7 @@ const MakeOpenDirAccessMaskWOptions = struct {
31903192 create_disposition: u32,
31913193};
31923194
3193fn dirClose(userdata: ?*anyopaque, dir: Io.Dir) void {
3195fn dirClose(userdata: ?*anyopaque, dir: Dir) void {
31943196 const t: *Threaded = @ptrCast(@alignCast(userdata));
31953197 _ = t;
31963198 posix.close(dir.handle);
......@@ -3201,7 +3203,7 @@ const dirRealPath = switch (native_os) {
32013203 else => dirRealPathPosix,
32023204};
32033205
3204fn dirRealPathWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, out_buffer: []u8) Io.Dir.RealPathError!usize {
3206fn dirRealPathWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, out_buffer: []u8) Dir.RealPathError!usize {
32053207 const t: *Threaded = @ptrCast(@alignCast(userdata));
32063208 const w = windows;
32073209 const current_thread = Thread.getCurrent(t);
......@@ -3237,7 +3239,7 @@ fn dirRealPathWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8,
32373239 return std.unicode.wtf16LeToWtf8(out_buffer, wide_slice);
32383240}
32393241
3240fn dirRealPathPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, out_buffer: []u8) Io.Dir.RealPathError!usize {
3242fn dirRealPathPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, out_buffer: []u8) Dir.RealPathError!usize {
32413243 if (native_os == .wasi) @compileError("unsupported operating system");
32423244 const max_path_bytes = std.fs.max_path_bytes;
32433245
......@@ -3434,11 +3436,11 @@ const dirDeleteFile = switch (native_os) {
34343436 else => dirDeleteFilePosix,
34353437};
34363438
3437fn dirDeleteFileWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void {
3439fn dirDeleteFileWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void {
34383440 return dirDeleteWindows(userdata, dir, sub_path, false);
34393441}
34403442
3441fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void {
3443fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void {
34423444 if (builtin.link_libc) return dirDeleteFilePosix(userdata, dir, sub_path);
34433445 const t: *Threaded = @ptrCast(@alignCast(userdata));
34443446 const current_thread = Thread.getCurrent(t);
......@@ -3482,7 +3484,7 @@ fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) I
34823484 }
34833485}
34843486
3485fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void {
3487fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void {
34863488 const t: *Threaded = @ptrCast(@alignCast(userdata));
34873489 const current_thread = Thread.getCurrent(t);
34883490
......@@ -3567,11 +3569,11 @@ const dirDeleteDir = switch (native_os) {
35673569 else => dirDeleteDirPosix,
35683570};
35693571
3570fn dirDeleteDirWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void {
3572fn dirDeleteDirWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void {
35713573 return dirDeleteWindows(userdata, dir, sub_path, true);
35723574}
35733575
3574fn dirDeleteWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, remove_dir: bool) Io.Dir.DeleteFileError!void {
3576fn dirDeleteWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, remove_dir: bool) Dir.DeleteFileError!void {
35753577 const t: *Threaded = @ptrCast(@alignCast(userdata));
35763578 const current_thread = Thread.getCurrent(t);
35773579 const w = windows;
......@@ -3712,7 +3714,7 @@ fn dirDeleteWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, re
37123714 }
37133715}
37143716
3715fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void {
3717fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void {
37163718 if (builtin.link_libc) return dirDeleteDirPosix(userdata, dir, sub_path);
37173719
37183720 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -3758,7 +3760,7 @@ fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io
37583760 }
37593761}
37603762
3761fn dirDeleteDirPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void {
3763fn dirDeleteDirPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void {
37623764 const t: *Threaded = @ptrCast(@alignCast(userdata));
37633765 const current_thread = Thread.getCurrent(t);
37643766
......@@ -3812,11 +3814,11 @@ const dirRename = switch (native_os) {
38123814
38133815fn dirRenameWindows(
38143816 userdata: ?*anyopaque,
3815 old_dir: Io.Dir,
3817 old_dir: Dir,
38163818 old_sub_path: []const u8,
3817 new_dir: Io.Dir,
3819 new_dir: Dir,
38183820 new_sub_path: []const u8,
3819) Io.Dir.RenameError!void {
3821) Dir.RenameError!void {
38203822 const w = windows;
38213823 const t: *Threaded = @ptrCast(@alignCast(userdata));
38223824 const current_thread = Thread.getCurrent(t);
......@@ -3935,11 +3937,11 @@ fn dirRenameWindows(
39353937
39363938fn dirRenameWasi(
39373939 userdata: ?*anyopaque,
3938 old_dir: Io.Dir,
3940 old_dir: Dir,
39393941 old_sub_path: []const u8,
3940 new_dir: Io.Dir,
3942 new_dir: Dir,
39413943 new_sub_path: []const u8,
3942) Io.Dir.RenameError!void {
3944) Dir.RenameError!void {
39433945 if (builtin.link_libc) return dirRenamePosix(userdata, old_dir, old_sub_path, new_dir, new_sub_path);
39443946
39453947 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -3986,11 +3988,11 @@ fn dirRenameWasi(
39863988
39873989fn dirRenamePosix(
39883990 userdata: ?*anyopaque,
3989 old_dir: Io.Dir,
3991 old_dir: Dir,
39903992 old_sub_path: []const u8,
3991 new_dir: Io.Dir,
3993 new_dir: Dir,
39923994 new_sub_path: []const u8,
3993) Io.Dir.RenameError!void {
3995) Dir.RenameError!void {
39943996 const t: *Threaded = @ptrCast(@alignCast(userdata));
39953997 const current_thread = Thread.getCurrent(t);
39963998
......@@ -4046,11 +4048,11 @@ const dirSymLink = switch (native_os) {
40464048
40474049fn dirSymLinkWindows(
40484050 userdata: ?*anyopaque,
4049 dir: Io.Dir,
4051 dir: Dir,
40504052 target_path: []const u8,
40514053 sym_link_path: []const u8,
4052 flags: Io.Dir.SymLinkFlags,
4053) Io.Dir.SymLinkError!void {
4054 flags: Dir.SymLinkFlags,
4055) Dir.SymLinkError!void {
40544056 const t: *Threaded = @ptrCast(@alignCast(userdata));
40554057 const current_thread = Thread.getCurrent(t);
40564058 const w = windows;
......@@ -4161,11 +4163,11 @@ fn dirSymLinkWindows(
41614163
41624164fn dirSymLinkWasi(
41634165 userdata: ?*anyopaque,
4164 dir: Io.Dir,
4166 dir: Dir,
41654167 target_path: []const u8,
41664168 sym_link_path: []const u8,
4167 flags: Io.Dir.SymLinkFlags,
4168) Io.Dir.SymLinkError!void {
4169 flags: Dir.SymLinkFlags,
4170) Dir.SymLinkError!void {
41694171 if (builtin.link_libc) return dirSymLinkPosix(dir, target_path, sym_link_path, flags);
41704172
41714173 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -4209,11 +4211,11 @@ fn dirSymLinkWasi(
42094211
42104212fn dirSymLinkPosix(
42114213 userdata: ?*anyopaque,
4212 dir: Io.Dir,
4214 dir: Dir,
42134215 target_path: []const u8,
42144216 sym_link_path: []const u8,
4215 flags: Io.Dir.SymLinkFlags,
4216) Io.Dir.SymLinkError!void {
4217 flags: Dir.SymLinkFlags,
4218) Dir.SymLinkError!void {
42174219 _ = flags;
42184220 const t: *Threaded = @ptrCast(@alignCast(userdata));
42194221 const current_thread = Thread.getCurrent(t);
......@@ -4264,7 +4266,7 @@ const dirReadLink = switch (native_os) {
42644266 else => dirReadLinkPosix,
42654267};
42664268
4267fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize {
4269fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize {
42684270 const t: *Threaded = @ptrCast(@alignCast(userdata));
42694271 const current_thread = Thread.getCurrent(t);
42704272 const w = windows;
......@@ -4322,7 +4324,7 @@ fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8,
43224324 return std.unicode.wtf16LeToWtf8(buffer, wide_result);
43234325}
43244326
4325fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize {
4327fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize {
43264328 if (builtin.link_libc) return dirReadLinkPosix(userdata, dir, sub_path, buffer);
43274329
43284330 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -4362,7 +4364,7 @@ fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buf
43624364 }
43634365}
43644366
4365fn dirReadLinkPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize {
4367fn dirReadLinkPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize {
43664368 const t: *Threaded = @ptrCast(@alignCast(userdata));
43674369 const current_thread = Thread.getCurrent(t);
43684370
......@@ -4408,7 +4410,7 @@ const dirSetPermissions = switch (native_os) {
44084410 else => dirSetPermissionsPosix,
44094411};
44104412
4411fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io.Dir.Permissions) Io.Dir.SetPermissionsError!void {
4413fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void {
44124414 // TODO I think we can actually set permissions on a dir on windows?
44134415 _ = userdata;
44144416 _ = dir;
......@@ -4416,7 +4418,7 @@ fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io.
44164418 return error.Unexpected;
44174419}
44184420
4419fn dirSetPermissionsPosix(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io.Dir.Permissions) Io.Dir.SetPermissionsError!void {
4421fn dirSetPermissionsPosix(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void {
44204422 const t: *Threaded = @ptrCast(@alignCast(userdata));
44214423 const current_thread = Thread.getCurrent(t);
44224424 return setPermissionsPosix(current_thread, dir.handle, permissions.toMode());
......@@ -4427,7 +4429,7 @@ const dirSetOwner = switch (native_os) {
44274429 else => dirSetOwnerPosix,
44284430};
44294431
4430fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.Dir.SetOwnerError!void {
4432fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void {
44314433 _ = userdata;
44324434 _ = dir;
44334435 _ = owner;
......@@ -4435,7 +4437,7 @@ fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Ui
44354437 return error.Unexpected;
44364438}
44374439
4438fn dirSetOwnerPosix(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.Dir.SetOwnerError!void {
4440fn dirSetOwnerPosix(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void {
44394441 const t: *Threaded = @ptrCast(@alignCast(userdata));
44404442 const current_thread = Thread.getCurrent(t);
44414443 const uid = owner orelse ~@as(posix.uid_t, 0);
......@@ -4443,7 +4445,7 @@ fn dirSetOwnerPosix(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Uid, gro
44434445 return setOwnerPosix(current_thread, dir.handle, uid, gid);
44444446}
44454447
4446fn setOwnerPosix(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid: posix.gid_t) Io.File.SetOwnerError!void {
4448fn setOwnerPosix(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid: posix.gid_t) File.SetOwnerError!void {
44474449 try current_thread.beginSyscall();
44484450 while (true) {
44494451 switch (posix.errno(posix.system.fchown(fd, uid, gid))) {
......@@ -4456,7 +4458,7 @@ fn setOwnerPosix(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid:
44564458 else => |e| {
44574459 current_thread.endSyscall();
44584460 switch (e) {
4459 .BADF => |err| return errnoBug(err), // likely fd refers to directory opened without `Io.Dir.OpenOptions.iterate`
4461 .BADF => |err| return errnoBug(err), // likely fd refers to directory opened without `Dir.OpenOptions.iterate`
44604462 .FAULT => |err| return errnoBug(err),
44614463 .INVAL => |err| return errnoBug(err),
44624464 .ACCES => return error.AccessDenied,
......@@ -4479,7 +4481,7 @@ const fileSync = switch (native_os) {
44794481 else => fileSyncPosix,
44804482};
44814483
4482fn fileSyncWindows(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void {
4484fn fileSyncWindows(userdata: ?*anyopaque, file: File) File.SyncError!void {
44834485 const t: *Threaded = @ptrCast(@alignCast(userdata));
44844486 const current_thread = Thread.getCurrent(t);
44854487
......@@ -4497,7 +4499,7 @@ fn fileSyncWindows(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void
44974499 }
44984500}
44994501
4500fn fileSyncPosix(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void {
4502fn fileSyncPosix(userdata: ?*anyopaque, file: File) File.SyncError!void {
45014503 const t: *Threaded = @ptrCast(@alignCast(userdata));
45024504 const current_thread = Thread.getCurrent(t);
45034505 try current_thread.beginSyscall();
......@@ -4525,13 +4527,13 @@ fn fileSyncPosix(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void {
45254527 }
45264528}
45274529
4528fn fileIsTty(userdata: ?*anyopaque, file: Io.File) Io.Cancelable!bool {
4530fn fileIsTty(userdata: ?*anyopaque, file: File) Io.Cancelable!bool {
45294531 const t: *Threaded = @ptrCast(@alignCast(userdata));
45304532 const current_thread = Thread.getCurrent(t);
45314533 return isTty(current_thread, file);
45324534}
45334535
4534fn isTty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool {
4536fn isTty(current_thread: *Thread, file: File) Io.Cancelable!bool {
45354537 if (is_windows) {
45364538 if (try isCygwinPty(current_thread, file)) return true;
45374539 try current_thread.checkCancel();
......@@ -4604,7 +4606,7 @@ fn isTty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool {
46044606 @compileError("unimplemented");
46054607}
46064608
4607fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.File.EnableAnsiEscapeCodesError!void {
4609fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: File) File.EnableAnsiEscapeCodesError!void {
46084610 const t: *Threaded = @ptrCast(@alignCast(userdata));
46094611 const current_thread = Thread.getCurrent(t);
46104612
......@@ -4639,13 +4641,13 @@ fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.File.Enabl
46394641 return error.NotTerminalDevice;
46404642}
46414643
4642fn fileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.Cancelable!bool {
4644fn fileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: File) Io.Cancelable!bool {
46434645 const t: *Threaded = @ptrCast(@alignCast(userdata));
46444646 const current_thread = Thread.getCurrent(t);
46454647 return supportsAnsiEscapeCodes(current_thread, file);
46464648}
46474649
4648fn supportsAnsiEscapeCodes(current_thread: *Thread, file: Io.File) Io.Cancelable!bool {
4650fn supportsAnsiEscapeCodes(current_thread: *Thread, file: File) Io.Cancelable!bool {
46494651 if (is_windows) {
46504652 try current_thread.checkCancel();
46514653 var console_mode: windows.DWORD = 0;
......@@ -4667,7 +4669,7 @@ fn supportsAnsiEscapeCodes(current_thread: *Thread, file: Io.File) Io.Cancelable
46674669 return false;
46684670}
46694671
4670fn isCygwinPty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool {
4672fn isCygwinPty(current_thread: *Thread, file: File) Io.Cancelable!bool {
46714673 if (!is_windows) return false;
46724674
46734675 const handle = file.handle;
......@@ -4721,7 +4723,7 @@ fn isCygwinPty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool {
47214723 std.mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
47224724}
47234725
4724fn fileSetLength(userdata: ?*anyopaque, file: Io.File, length: u64) Io.File.SetLengthError!void {
4726fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void {
47254727 const t: *Threaded = @ptrCast(@alignCast(userdata));
47264728 const current_thread = Thread.getCurrent(t);
47274729
......@@ -4805,7 +4807,7 @@ fn fileSetLength(userdata: ?*anyopaque, file: Io.File, length: u64) Io.File.SetL
48054807 }
48064808}
48074809
4808fn fileSetOwner(userdata: ?*anyopaque, file: Io.File, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.File.SetOwnerError!void {
4810fn fileSetOwner(userdata: ?*anyopaque, file: File, owner: ?File.Uid, group: ?File.Gid) File.SetOwnerError!void {
48094811 switch (native_os) {
48104812 .windows, .wasi => return error.Unexpected,
48114813 else => {},
......@@ -4817,7 +4819,7 @@ fn fileSetOwner(userdata: ?*anyopaque, file: Io.File, owner: ?Io.File.Uid, group
48174819 return setOwnerPosix(current_thread, file.handle, uid, gid);
48184820}
48194821
4820fn fileSetPermissions(userdata: ?*anyopaque, file: Io.File, permissions: Io.File.Permissions) Io.File.SetPermissionsError!void {
4822fn fileSetPermissions(userdata: ?*anyopaque, file: File, permissions: File.Permissions) File.SetPermissionsError!void {
48214823 const t: *Threaded = @ptrCast(@alignCast(userdata));
48224824 const current_thread = Thread.getCurrent(t);
48234825 switch (native_os) {
......@@ -4850,7 +4852,7 @@ fn fileSetPermissions(userdata: ?*anyopaque, file: Io.File, permissions: Io.File
48504852 }
48514853}
48524854
4853fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode_t) Io.File.SetPermissionsError!void {
4855fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode_t) File.SetPermissionsError!void {
48544856 try current_thread.beginSyscall();
48554857 while (true) {
48564858 switch (posix.errno(posix.system.fchmod(fd, mode))) {
......@@ -4883,12 +4885,12 @@ fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode
48834885
48844886fn dirSetTimestamps(
48854887 userdata: ?*anyopaque,
4886 dir: Io.Dir,
4888 dir: Dir,
48874889 sub_path: []const u8,
48884890 last_accessed: Io.Timestamp,
48894891 last_modified: Io.Timestamp,
4890 options: Io.File.SetTimestampsOptions,
4891) Io.File.SetTimestampsError!void {
4892 options: File.SetTimestampsOptions,
4893) File.SetTimestampsError!void {
48924894 const t: *Threaded = @ptrCast(@alignCast(userdata));
48934895 const current_thread = Thread.getCurrent(t);
48944896
......@@ -4937,10 +4939,10 @@ fn dirSetTimestamps(
49374939
49384940fn dirSetTimestampsNow(
49394941 userdata: ?*anyopaque,
4940 dir: Io.Dir,
4942 dir: Dir,
49414943 sub_path: []const u8,
4942 options: Io.File.SetTimestampsOptions,
4943) Io.File.SetTimestampsError!void {
4944 options: File.SetTimestampsOptions,
4945) File.SetTimestampsError!void {
49444946 const t: *Threaded = @ptrCast(@alignCast(userdata));
49454947 const current_thread = Thread.getCurrent(t);
49464948
......@@ -4984,10 +4986,10 @@ fn dirSetTimestampsNow(
49844986
49854987fn fileSetTimestamps(
49864988 userdata: ?*anyopaque,
4987 file: Io.File,
4989 file: File,
49884990 last_accessed: Io.Timestamp,
49894991 last_modified: Io.Timestamp,
4990) Io.File.SetTimestampsError!void {
4992) File.SetTimestampsError!void {
49914993 const t: *Threaded = @ptrCast(@alignCast(userdata));
49924994 const current_thread = Thread.getCurrent(t);
49934995
......@@ -5068,7 +5070,7 @@ fn fileSetTimestamps(
50685070 }
50695071}
50705072
5071fn fileSetTimestampsNow(userdata: ?*anyopaque, file: Io.File) Io.File.SetTimestampsError!void {
5073fn fileSetTimestampsNow(userdata: ?*anyopaque, file: File) File.SetTimestampsError!void {
50725074 const t: *Threaded = @ptrCast(@alignCast(userdata));
50735075 const current_thread = Thread.getCurrent(t);
50745076
......@@ -5133,7 +5135,7 @@ fn fileSetTimestampsNow(userdata: ?*anyopaque, file: Io.File) Io.File.SetTimesta
51335135const windows_lock_range_off: windows.LARGE_INTEGER = 0;
51345136const windows_lock_range_len: windows.LARGE_INTEGER = 1;
51355137
5136fn fileLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.LockError!void {
5138fn fileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!void {
51375139 const t: *Threaded = @ptrCast(@alignCast(userdata));
51385140 const current_thread = Thread.getCurrent(t);
51395141
......@@ -5195,7 +5197,7 @@ fn fileLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.Lo
51955197 }
51965198}
51975199
5198fn fileTryLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.LockError!bool {
5200fn fileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!bool {
51995201 const t: *Threaded = @ptrCast(@alignCast(userdata));
52005202 const current_thread = Thread.getCurrent(t);
52015203
......@@ -5263,7 +5265,7 @@ fn fileTryLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File
52635265 }
52645266}
52655267
5266fn fileUnlock(userdata: ?*anyopaque, file: Io.File) void {
5268fn fileUnlock(userdata: ?*anyopaque, file: File) void {
52675269 const t: *Threaded = @ptrCast(@alignCast(userdata));
52685270 const current_thread = Thread.getCurrent(t);
52695271
......@@ -5311,7 +5313,7 @@ fn fileUnlock(userdata: ?*anyopaque, file: Io.File) void {
53115313 }
53125314}
53135315
5314fn fileDowngradeLock(userdata: ?*anyopaque, file: Io.File) Io.File.DowngradeLockError!void {
5316fn fileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!void {
53155317 const t: *Threaded = @ptrCast(@alignCast(userdata));
53165318 const current_thread = Thread.getCurrent(t);
53175319
......@@ -5388,10 +5390,10 @@ fn fileDowngradeLock(userdata: ?*anyopaque, file: Io.File) Io.File.DowngradeLock
53885390
53895391fn dirOpenDirWasi(
53905392 userdata: ?*anyopaque,
5391 dir: Io.Dir,
5393 dir: Dir,
53925394 sub_path: []const u8,
5393 options: Io.Dir.OpenOptions,
5394) Io.Dir.OpenError!Io.Dir {
5395 options: Dir.OpenOptions,
5396) Dir.OpenError!Dir {
53955397 if (builtin.link_libc) return dirOpenDirPosix(userdata, dir, sub_path, options);
53965398 const t: *Threaded = @ptrCast(@alignCast(userdata));
53975399 const current_thread = Thread.getCurrent(t);
......@@ -5462,7 +5464,7 @@ fn dirOpenDirWasi(
54625464 }
54635465}
54645466
5465fn fileClose(userdata: ?*anyopaque, file: Io.File) void {
5467fn fileClose(userdata: ?*anyopaque, file: File) void {
54665468 const t: *Threaded = @ptrCast(@alignCast(userdata));
54675469 _ = t;
54685470 posix.close(file.handle);
......@@ -5473,7 +5475,7 @@ const fileReadStreaming = switch (native_os) {
54735475 else => fileReadStreamingPosix,
54745476};
54755477
5476fn fileReadStreamingPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File.Reader.Error!usize {
5478fn fileReadStreamingPosix(userdata: ?*anyopaque, file: File, data: [][]u8) File.Reader.Error!usize {
54775479 const t: *Threaded = @ptrCast(@alignCast(userdata));
54785480 const current_thread = Thread.getCurrent(t);
54795481
......@@ -5562,7 +5564,7 @@ fn fileReadStreamingPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io
55625564 }
55635565}
55645566
5565fn fileReadStreamingWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File.Reader.Error!usize {
5567fn fileReadStreamingWindows(userdata: ?*anyopaque, file: File, data: [][]u8) File.Reader.Error!usize {
55665568 const t: *Threaded = @ptrCast(@alignCast(userdata));
55675569 const current_thread = Thread.getCurrent(t);
55685570
......@@ -5591,7 +5593,7 @@ fn fileReadStreamingWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8)
55915593 }
55925594}
55935595
5594fn fileReadPositionalPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset: u64) Io.File.ReadPositionalError!usize {
5596fn fileReadPositionalPosix(userdata: ?*anyopaque, file: File, data: [][]u8, offset: u64) File.ReadPositionalError!usize {
55955597 const t: *Threaded = @ptrCast(@alignCast(userdata));
55965598 const current_thread = Thread.getCurrent(t);
55975599
......@@ -5694,7 +5696,7 @@ const fileReadPositional = switch (native_os) {
56945696 else => fileReadPositionalPosix,
56955697};
56965698
5697fn fileReadPositionalWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset: u64) Io.File.ReadPositionalError!usize {
5699fn fileReadPositionalWindows(userdata: ?*anyopaque, file: File, data: [][]u8, offset: u64) File.ReadPositionalError!usize {
56985700 const t: *Threaded = @ptrCast(@alignCast(userdata));
56995701 const current_thread = Thread.getCurrent(t);
57005702
......@@ -5736,7 +5738,7 @@ fn fileReadPositionalWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8,
57365738 }
57375739}
57385740
5739fn fileSeekBy(userdata: ?*anyopaque, file: Io.File, offset: i64) Io.File.SeekError!void {
5741fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!void {
57405742 const t: *Threaded = @ptrCast(@alignCast(userdata));
57415743 const current_thread = Thread.getCurrent(t);
57425744 const fd = file.handle;
......@@ -5834,7 +5836,7 @@ fn fileSeekBy(userdata: ?*anyopaque, file: Io.File, offset: i64) Io.File.SeekErr
58345836 }
58355837}
58365838
5837fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekError!void {
5839fn fileSeekTo(userdata: ?*anyopaque, file: File, offset: u64) File.SeekError!void {
58385840 const t: *Threaded = @ptrCast(@alignCast(userdata));
58395841 const current_thread = Thread.getCurrent(t);
58405842 const fd = file.handle;
......@@ -5930,7 +5932,7 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr
59305932 }
59315933}
59325934
5933fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelfExeError!Io.File {
5935fn openSelfExe(userdata: ?*anyopaque, flags: File.OpenFlags) File.OpenSelfExeError!File {
59345936 const t: *Threaded = @ptrCast(@alignCast(userdata));
59355937 switch (native_os) {
59365938 .linux, .serenity => return dirOpenFilePosix(t, .{ .handle = posix.AT.FDCWD }, "/proc/self/exe", flags),
......@@ -5949,12 +5951,12 @@ fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelf
59495951
59505952fn fileWritePositional(
59515953 userdata: ?*anyopaque,
5952 file: Io.File,
5954 file: File,
59535955 header: []const u8,
59545956 data: []const []const u8,
59555957 splat: usize,
59565958 offset: u64,
5957) Io.File.WritePositionalError!usize {
5959) File.WritePositionalError!usize {
59585960 const t: *Threaded = @ptrCast(@alignCast(userdata));
59595961 const current_thread = Thread.getCurrent(t);
59605962
......@@ -6071,11 +6073,11 @@ fn fileWritePositional(
60716073
60726074fn fileWriteStreaming(
60736075 userdata: ?*anyopaque,
6074 file: Io.File,
6076 file: File,
60756077 header: []const u8,
60766078 data: []const []const u8,
60776079 splat: usize,
6078) Io.File.WriteStreamingError!usize {
6080) File.WriteStreamingError!usize {
60796081 const t: *Threaded = @ptrCast(@alignCast(userdata));
60806082 const current_thread = Thread.getCurrent(t);
60816083
......@@ -6187,11 +6189,11 @@ fn fileWriteStreaming(
61876189
61886190fn fileWriteFileStreaming(
61896191 userdata: ?*anyopaque,
6190 file: Io.File,
6192 file: File,
61916193 header: []const u8,
6192 file_reader: *Io.File.Reader,
6194 file_reader: *File.Reader,
61936195 limit: Io.Limit,
6194) Io.File.WriteFileStreamingError!usize {
6196) File.WriteFileStreamingError!usize {
61956197 const t: *Threaded = @ptrCast(@alignCast(userdata));
61966198 const reader_buffered = file_reader.interface.buffered();
61976199 if (reader_buffered.len >= @intFromEnum(limit)) {
......@@ -6585,7 +6587,7 @@ fn netWriteFile(
65856587 userdata: ?*anyopaque,
65866588 socket_handle: net.Socket.Handle,
65876589 header: []const u8,
6588 file_reader: *Io.File.Reader,
6590 file_reader: *File.Reader,
65896591 limit: Io.Limit,
65906592) net.Stream.WriteFileError!usize {
65916593 const t: *Threaded = @ptrCast(@alignCast(userdata));
......@@ -6599,12 +6601,12 @@ fn netWriteFile(
65996601
66006602fn fileWriteFilePositional(
66016603 userdata: ?*anyopaque,
6602 file: Io.File,
6604 file: File,
66036605 header: []const u8,
6604 file_reader: *Io.File.Reader,
6606 file_reader: *File.Reader,
66056607 limit: Io.Limit,
66066608 offset: u64,
6607) Io.File.WriteFilePositionalError!usize {
6609) File.WriteFilePositionalError!usize {
66086610 const t: *Threaded = @ptrCast(@alignCast(userdata));
66096611 const reader_buffered = file_reader.interface.buffered();
66106612 if (reader_buffered.len >= @intFromEnum(limit)) {
......@@ -9488,7 +9490,7 @@ fn clockToWasi(clock: Io.Clock) std.os.wasi.clockid_t {
94889490 };
94899491}
94909492
9491fn statFromLinux(stx: *const std.os.linux.Statx) Io.File.Stat {
9493fn statFromLinux(stx: *const std.os.linux.Statx) File.Stat {
94929494 const atime = stx.atime;
94939495 const mtime = stx.mtime;
94949496 const ctime = stx.ctime;
......@@ -9512,7 +9514,7 @@ fn statFromLinux(stx: *const std.os.linux.Statx) Io.File.Stat {
95129514 };
95139515}
95149516
9515fn statFromPosix(st: *const posix.Stat) Io.File.Stat {
9517fn statFromPosix(st: *const posix.Stat) File.Stat {
95169518 const atime = st.atime();
95179519 const mtime = st.mtime();
95189520 const ctime = st.ctime();
......@@ -9546,7 +9548,7 @@ fn statFromPosix(st: *const posix.Stat) Io.File.Stat {
95469548 };
95479549}
95489550
9549fn statFromWasi(st: *const std.os.wasi.filestat_t) Io.File.Stat {
9551fn statFromWasi(st: *const std.os.wasi.filestat_t) File.Stat {
95509552 return .{
95519553 .inode = st.ino,
95529554 .size = @bitCast(st.size),
......@@ -9577,7 +9579,7 @@ fn timestampToPosix(nanoseconds: i96) posix.timespec {
95779579 };
95789580}
95799581
9580fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Io.Dir.PathNameError![:0]u8 {
9582fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Dir.PathNameError![:0]u8 {
95819583 if (std.mem.containsAtLeastScalar2(u8, file_path, 0, 1)) return error.BadPathName;
95829584 // >= rather than > to make room for the null byte
95839585 if (file_path.len >= buffer.len) return error.NameTooLong;
......@@ -9824,7 +9826,7 @@ fn lookupHosts(
98249826 options: HostName.LookupOptions,
98259827) !void {
98269828 const t_io = io(t);
9827 const file = Io.File.openAbsolute(t_io, "/etc/hosts", .{}) catch |err| switch (err) {
9829 const file = File.openAbsolute(t_io, "/etc/hosts", .{}) catch |err| switch (err) {
98289830 error.FileNotFound,
98299831 error.NotDir,
98309832 error.AccessDenied,