| ... | ... | @@ -11,6 +11,8 @@ const is_debug = builtin.mode == .Debug; |
| 11 | 11 | const std = @import("../std.zig"); |
| 12 | 12 | const Io = std.Io; |
| 13 | 13 | const net = std.Io.net; |
| 14 | const File = std.Io.File; |
| 15 | const Dir = std.Dir; |
| 14 | 16 | const HostName = std.Io.net.HostName; |
| 15 | 17 | const IpAddress = std.Io.net.IpAddress; |
| 16 | 18 | const Allocator = std.mem.Allocator; |
| ... | ... | @@ -1444,7 +1446,7 @@ const dirMake = switch (native_os) { |
| 1444 | 1446 | else => dirMakePosix, |
| 1445 | 1447 | }; |
| 1446 | 1448 | |
| 1447 | | fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void { |
| 1449 | fn dirMakePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void { |
| 1448 | 1450 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1449 | 1451 | const current_thread = Thread.getCurrent(t); |
| 1450 | 1452 | |
| ... | ... | @@ -1490,7 +1492,7 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: |
| 1490 | 1492 | } |
| 1491 | 1493 | } |
| 1492 | 1494 | |
| 1493 | | fn dirMakeWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void { |
| 1495 | fn dirMakeWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void { |
| 1494 | 1496 | if (builtin.link_libc) return dirMakePosix(userdata, dir, sub_path, mode); |
| 1495 | 1497 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1496 | 1498 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -1532,7 +1534,7 @@ fn dirMakeWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: I |
| 1532 | 1534 | } |
| 1533 | 1535 | } |
| 1534 | 1536 | |
| 1535 | | fn dirMakeWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: Io.Dir.Mode) Io.Dir.MakeError!void { |
| 1537 | fn dirMakeWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void { |
| 1536 | 1538 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1537 | 1539 | const current_thread = Thread.getCurrent(t); |
| 1538 | 1540 | try current_thread.checkCancel(); |
| ... | ... | @@ -1560,14 +1562,14 @@ fn dirMakeWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode |
| 1560 | 1562 | |
| 1561 | 1563 | fn dirMakePath( |
| 1562 | 1564 | userdata: ?*anyopaque, |
| 1563 | | dir: Io.Dir, |
| 1565 | dir: Dir, |
| 1564 | 1566 | 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 { |
| 1567 | 1569 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1568 | 1570 | |
| 1569 | 1571 | var it = std.fs.path.componentIterator(sub_path); |
| 1570 | | var status: Io.Dir.MakePathStatus = .existed; |
| 1572 | var status: Dir.MakePathStatus = .existed; |
| 1571 | 1573 | var component = it.last() orelse return error.BadPathName; |
| 1572 | 1574 | while (true) { |
| 1573 | 1575 | if (dirMake(t, dir, component.path, mode)) |_| { |
| ... | ... | @@ -1604,10 +1606,10 @@ const dirMakeOpenPath = switch (native_os) { |
| 1604 | 1606 | |
| 1605 | 1607 | fn dirMakeOpenPathPosix( |
| 1606 | 1608 | userdata: ?*anyopaque, |
| 1607 | | dir: Io.Dir, |
| 1609 | dir: Dir, |
| 1608 | 1610 | sub_path: []const u8, |
| 1609 | | options: Io.Dir.OpenOptions, |
| 1610 | | ) Io.Dir.MakeOpenPathError!Io.Dir { |
| 1611 | options: Dir.OpenOptions, |
| 1612 | ) Dir.MakeOpenPathError!Dir { |
| 1611 | 1613 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1612 | 1614 | const t_io = ioBasic(t); |
| 1613 | 1615 | return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) { |
| ... | ... | @@ -1621,10 +1623,10 @@ fn dirMakeOpenPathPosix( |
| 1621 | 1623 | |
| 1622 | 1624 | fn dirMakeOpenPathWindows( |
| 1623 | 1625 | userdata: ?*anyopaque, |
| 1624 | | dir: Io.Dir, |
| 1626 | dir: Dir, |
| 1625 | 1627 | sub_path: []const u8, |
| 1626 | | options: Io.Dir.OpenOptions, |
| 1627 | | ) Io.Dir.MakeOpenPathError!Io.Dir { |
| 1628 | options: Dir.OpenOptions, |
| 1629 | ) Dir.MakeOpenPathError!Dir { |
| 1628 | 1630 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1629 | 1631 | const current_thread = Thread.getCurrent(t); |
| 1630 | 1632 | const w = windows; |
| ... | ... | @@ -1644,7 +1646,7 @@ fn dirMakeOpenPathWindows( |
| 1644 | 1646 | const is_last = it.peekNext() == null; |
| 1645 | 1647 | const create_disposition: w.FILE.CREATE_DISPOSITION = if (is_last) .OPEN_IF else .CREATE; |
| 1646 | 1648 | |
| 1647 | | var result: Io.Dir = .{ .handle = undefined }; |
| 1649 | var result: Dir = .{ .handle = undefined }; |
| 1648 | 1650 | |
| 1649 | 1651 | const path_len_bytes: u16 = @intCast(sub_path_w.len * 2); |
| 1650 | 1652 | var nt_name: w.UNICODE_STRING = .{ |
| ... | ... | @@ -1736,10 +1738,10 @@ fn dirMakeOpenPathWindows( |
| 1736 | 1738 | |
| 1737 | 1739 | fn dirMakeOpenPathWasi( |
| 1738 | 1740 | userdata: ?*anyopaque, |
| 1739 | | dir: Io.Dir, |
| 1741 | dir: Dir, |
| 1740 | 1742 | sub_path: []const u8, |
| 1741 | | options: Io.Dir.OpenOptions, |
| 1742 | | ) Io.Dir.MakeOpenPathError!Io.Dir { |
| 1743 | options: Dir.OpenOptions, |
| 1744 | ) Dir.MakeOpenPathError!Dir { |
| 1743 | 1745 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1744 | 1746 | const t_io = ioBasic(t); |
| 1745 | 1747 | return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) { |
| ... | ... | @@ -1751,9 +1753,9 @@ fn dirMakeOpenPathWasi( |
| 1751 | 1753 | }; |
| 1752 | 1754 | } |
| 1753 | 1755 | |
| 1754 | | fn dirStat(userdata: ?*anyopaque, dir: Io.Dir) Io.Dir.StatError!Io.Dir.Stat { |
| 1756 | fn dirStat(userdata: ?*anyopaque, dir: Dir) Dir.StatError!Dir.Stat { |
| 1755 | 1757 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1756 | | const file: Io.File = .{ .handle = dir.handle }; |
| 1758 | const file: File = .{ .handle = dir.handle }; |
| 1757 | 1759 | return fileStat(t, file); |
| 1758 | 1760 | } |
| 1759 | 1761 | |
| ... | ... | @@ -1766,10 +1768,10 @@ const dirStatPath = switch (native_os) { |
| 1766 | 1768 | |
| 1767 | 1769 | fn dirStatPathLinux( |
| 1768 | 1770 | userdata: ?*anyopaque, |
| 1769 | | dir: Io.Dir, |
| 1771 | dir: Dir, |
| 1770 | 1772 | 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 { |
| 1773 | 1775 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1774 | 1776 | const current_thread = Thread.getCurrent(t); |
| 1775 | 1777 | const linux = std.os.linux; |
| ... | ... | @@ -1828,10 +1830,10 @@ fn dirStatPathLinux( |
| 1828 | 1830 | |
| 1829 | 1831 | fn dirStatPathPosix( |
| 1830 | 1832 | userdata: ?*anyopaque, |
| 1831 | | dir: Io.Dir, |
| 1833 | dir: Dir, |
| 1832 | 1834 | 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 { |
| 1835 | 1837 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1836 | 1838 | const current_thread = Thread.getCurrent(t); |
| 1837 | 1839 | |
| ... | ... | @@ -1876,10 +1878,10 @@ fn dirStatPathPosix( |
| 1876 | 1878 | |
| 1877 | 1879 | fn dirStatPathWindows( |
| 1878 | 1880 | userdata: ?*anyopaque, |
| 1879 | | dir: Io.Dir, |
| 1881 | dir: Dir, |
| 1880 | 1882 | 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 { |
| 1883 | 1885 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1884 | 1886 | const file = try dirOpenFileWindows(t, dir, sub_path, .{ |
| 1885 | 1887 | .follow_symlinks = options.follow_symlinks, |
| ... | ... | @@ -1890,10 +1892,10 @@ fn dirStatPathWindows( |
| 1890 | 1892 | |
| 1891 | 1893 | fn dirStatPathWasi( |
| 1892 | 1894 | userdata: ?*anyopaque, |
| 1893 | | dir: Io.Dir, |
| 1895 | dir: Dir, |
| 1894 | 1896 | 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 { |
| 1897 | 1899 | if (builtin.link_libc) return dirStatPathPosix(userdata, dir, sub_path, options); |
| 1898 | 1900 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1899 | 1901 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -1941,7 +1943,7 @@ const fileStat = switch (native_os) { |
| 1941 | 1943 | else => fileStatPosix, |
| 1942 | 1944 | }; |
| 1943 | 1945 | |
| 1944 | | fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat { |
| 1946 | fn fileStatPosix(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { |
| 1945 | 1947 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1946 | 1948 | const current_thread = Thread.getCurrent(t); |
| 1947 | 1949 | |
| ... | ... | @@ -1974,7 +1976,7 @@ fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File |
| 1974 | 1976 | } |
| 1975 | 1977 | } |
| 1976 | 1978 | |
| 1977 | | fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat { |
| 1979 | fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { |
| 1978 | 1980 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 1979 | 1981 | const current_thread = Thread.getCurrent(t); |
| 1980 | 1982 | const linux = std.os.linux; |
| ... | ... | @@ -2025,7 +2027,7 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File |
| 2025 | 2027 | } |
| 2026 | 2028 | } |
| 2027 | 2029 | |
| 2028 | | fn fileStatWindows(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat { |
| 2030 | fn fileStatWindows(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { |
| 2029 | 2031 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2030 | 2032 | const current_thread = Thread.getCurrent(t); |
| 2031 | 2033 | try current_thread.checkCancel(); |
| ... | ... | @@ -2071,7 +2073,7 @@ fn fileStatWindows(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.Fi |
| 2071 | 2073 | }; |
| 2072 | 2074 | } |
| 2073 | 2075 | |
| 2074 | | fn fileStatWasi(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File.Stat { |
| 2076 | fn fileStatWasi(userdata: ?*anyopaque, file: File) File.StatError!File.Stat { |
| 2075 | 2077 | if (builtin.link_libc) return fileStatPosix(userdata, file); |
| 2076 | 2078 | |
| 2077 | 2079 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -2113,10 +2115,10 @@ const dirAccess = switch (native_os) { |
| 2113 | 2115 | |
| 2114 | 2116 | fn dirAccessPosix( |
| 2115 | 2117 | userdata: ?*anyopaque, |
| 2116 | | dir: Io.Dir, |
| 2118 | dir: Dir, |
| 2117 | 2119 | sub_path: []const u8, |
| 2118 | | options: Io.Dir.AccessOptions, |
| 2119 | | ) Io.Dir.AccessError!void { |
| 2120 | options: Dir.AccessOptions, |
| 2121 | ) Dir.AccessError!void { |
| 2120 | 2122 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2121 | 2123 | const current_thread = Thread.getCurrent(t); |
| 2122 | 2124 | |
| ... | ... | @@ -2167,10 +2169,10 @@ fn dirAccessPosix( |
| 2167 | 2169 | |
| 2168 | 2170 | fn dirAccessWasi( |
| 2169 | 2171 | userdata: ?*anyopaque, |
| 2170 | | dir: Io.Dir, |
| 2172 | dir: Dir, |
| 2171 | 2173 | sub_path: []const u8, |
| 2172 | | options: Io.Dir.AccessOptions, |
| 2173 | | ) Io.Dir.AccessError!void { |
| 2174 | options: Dir.AccessOptions, |
| 2175 | ) Dir.AccessError!void { |
| 2174 | 2176 | if (builtin.link_libc) return dirAccessPosix(userdata, dir, sub_path, options); |
| 2175 | 2177 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2176 | 2178 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -2240,10 +2242,10 @@ fn dirAccessWasi( |
| 2240 | 2242 | |
| 2241 | 2243 | fn dirAccessWindows( |
| 2242 | 2244 | userdata: ?*anyopaque, |
| 2243 | | dir: Io.Dir, |
| 2245 | dir: Dir, |
| 2244 | 2246 | sub_path: []const u8, |
| 2245 | | options: Io.Dir.AccessOptions, |
| 2246 | | ) Io.Dir.AccessError!void { |
| 2247 | options: Dir.AccessOptions, |
| 2248 | ) Dir.AccessError!void { |
| 2247 | 2249 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2248 | 2250 | const current_thread = Thread.getCurrent(t); |
| 2249 | 2251 | try current_thread.checkCancel(); |
| ... | ... | @@ -2292,10 +2294,10 @@ const dirCreateFile = switch (native_os) { |
| 2292 | 2294 | |
| 2293 | 2295 | fn dirCreateFilePosix( |
| 2294 | 2296 | userdata: ?*anyopaque, |
| 2295 | | dir: Io.Dir, |
| 2297 | dir: Dir, |
| 2296 | 2298 | sub_path: []const u8, |
| 2297 | | flags: Io.File.CreateFlags, |
| 2298 | | ) Io.File.OpenError!Io.File { |
| 2299 | flags: File.CreateFlags, |
| 2300 | ) File.OpenError!File { |
| 2299 | 2301 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2300 | 2302 | const current_thread = Thread.getCurrent(t); |
| 2301 | 2303 | |
| ... | ... | @@ -2455,10 +2457,10 @@ fn dirCreateFilePosix( |
| 2455 | 2457 | |
| 2456 | 2458 | fn dirCreateFileWindows( |
| 2457 | 2459 | userdata: ?*anyopaque, |
| 2458 | | dir: Io.Dir, |
| 2460 | dir: Dir, |
| 2459 | 2461 | sub_path: []const u8, |
| 2460 | | flags: Io.File.CreateFlags, |
| 2461 | | ) Io.File.OpenError!Io.File { |
| 2462 | flags: File.CreateFlags, |
| 2463 | ) File.OpenError!File { |
| 2462 | 2464 | const w = windows; |
| 2463 | 2465 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2464 | 2466 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -2509,10 +2511,10 @@ fn dirCreateFileWindows( |
| 2509 | 2511 | |
| 2510 | 2512 | fn dirCreateFileWasi( |
| 2511 | 2513 | userdata: ?*anyopaque, |
| 2512 | | dir: Io.Dir, |
| 2514 | dir: Dir, |
| 2513 | 2515 | sub_path: []const u8, |
| 2514 | | flags: Io.File.CreateFlags, |
| 2515 | | ) Io.File.OpenError!Io.File { |
| 2516 | flags: File.CreateFlags, |
| 2517 | ) File.OpenError!File { |
| 2516 | 2518 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2517 | 2519 | const current_thread = Thread.getCurrent(t); |
| 2518 | 2520 | const wasi = std.os.wasi; |
| ... | ... | @@ -2593,10 +2595,10 @@ const dirOpenFile = switch (native_os) { |
| 2593 | 2595 | |
| 2594 | 2596 | fn dirOpenFilePosix( |
| 2595 | 2597 | userdata: ?*anyopaque, |
| 2596 | | dir: Io.Dir, |
| 2598 | dir: Dir, |
| 2597 | 2599 | sub_path: []const u8, |
| 2598 | | flags: Io.File.OpenFlags, |
| 2599 | | ) Io.File.OpenError!Io.File { |
| 2600 | flags: File.OpenFlags, |
| 2601 | ) File.OpenError!File { |
| 2600 | 2602 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2601 | 2603 | const current_thread = Thread.getCurrent(t); |
| 2602 | 2604 | |
| ... | ... | @@ -2765,10 +2767,10 @@ fn dirOpenFilePosix( |
| 2765 | 2767 | |
| 2766 | 2768 | fn dirOpenFileWindows( |
| 2767 | 2769 | userdata: ?*anyopaque, |
| 2768 | | dir: Io.Dir, |
| 2770 | dir: Dir, |
| 2769 | 2771 | sub_path: []const u8, |
| 2770 | | flags: Io.File.OpenFlags, |
| 2771 | | ) Io.File.OpenError!Io.File { |
| 2772 | flags: File.OpenFlags, |
| 2773 | ) File.OpenError!File { |
| 2772 | 2774 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2773 | 2775 | const sub_path_w_array = try windows.sliceToPrefixedFileW(dir.handle, sub_path); |
| 2774 | 2776 | const sub_path_w = sub_path_w_array.span(); |
| ... | ... | @@ -2780,8 +2782,8 @@ pub fn dirOpenFileWtf16( |
| 2780 | 2782 | t: *Threaded, |
| 2781 | 2783 | dir_handle: ?windows.HANDLE, |
| 2782 | 2784 | 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 { |
| 2785 | 2787 | if (std.mem.eql(u16, sub_path_w, &.{'.'})) return error.IsDir; |
| 2786 | 2788 | if (std.mem.eql(u16, sub_path_w, &.{ '.', '.' })) return error.IsDir; |
| 2787 | 2789 | const path_len_bytes = std.math.cast(u16, sub_path_w.len * 2) orelse return error.NameTooLong; |
| ... | ... | @@ -2904,10 +2906,10 @@ pub fn dirOpenFileWtf16( |
| 2904 | 2906 | |
| 2905 | 2907 | fn dirOpenFileWasi( |
| 2906 | 2908 | userdata: ?*anyopaque, |
| 2907 | | dir: Io.Dir, |
| 2909 | dir: Dir, |
| 2908 | 2910 | sub_path: []const u8, |
| 2909 | | flags: Io.File.OpenFlags, |
| 2910 | | ) Io.File.OpenError!Io.File { |
| 2911 | flags: File.OpenFlags, |
| 2912 | ) File.OpenError!File { |
| 2911 | 2913 | if (builtin.link_libc) return dirOpenFilePosix(userdata, dir, sub_path, flags); |
| 2912 | 2914 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2913 | 2915 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -2991,10 +2993,10 @@ const dirOpenDir = switch (native_os) { |
| 2991 | 2993 | /// This function is also used for WASI when libc is linked. |
| 2992 | 2994 | fn dirOpenDirPosix( |
| 2993 | 2995 | userdata: ?*anyopaque, |
| 2994 | | dir: Io.Dir, |
| 2996 | dir: Dir, |
| 2995 | 2997 | sub_path: []const u8, |
| 2996 | | options: Io.Dir.OpenOptions, |
| 2997 | | ) Io.Dir.OpenError!Io.Dir { |
| 2998 | options: Dir.OpenOptions, |
| 2999 | ) Dir.OpenError!Dir { |
| 2998 | 3000 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2999 | 3001 | |
| 3000 | 3002 | if (is_windows) { |
| ... | ... | @@ -3065,10 +3067,10 @@ fn dirOpenDirPosix( |
| 3065 | 3067 | |
| 3066 | 3068 | fn dirOpenDirHaiku( |
| 3067 | 3069 | userdata: ?*anyopaque, |
| 3068 | | dir: Io.Dir, |
| 3070 | dir: Dir, |
| 3069 | 3071 | sub_path: []const u8, |
| 3070 | | options: Io.Dir.OpenOptions, |
| 3071 | | ) Io.Dir.OpenError!Io.Dir { |
| 3072 | options: Dir.OpenOptions, |
| 3073 | ) Dir.OpenError!Dir { |
| 3072 | 3074 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3073 | 3075 | const current_thread = Thread.getCurrent(t); |
| 3074 | 3076 | |
| ... | ... | @@ -3116,10 +3118,10 @@ fn dirOpenDirHaiku( |
| 3116 | 3118 | |
| 3117 | 3119 | pub fn dirOpenDirWindows( |
| 3118 | 3120 | t: *Io.Threaded, |
| 3119 | | dir: Io.Dir, |
| 3121 | dir: Dir, |
| 3120 | 3122 | 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 { |
| 3123 | 3125 | const current_thread = Thread.getCurrent(t); |
| 3124 | 3126 | const w = windows; |
| 3125 | 3127 | |
| ... | ... | @@ -3130,7 +3132,7 @@ pub fn dirOpenDirWindows( |
| 3130 | 3132 | .Buffer = @constCast(sub_path_w.ptr), |
| 3131 | 3133 | }; |
| 3132 | 3134 | var io_status_block: w.IO_STATUS_BLOCK = undefined; |
| 3133 | | var result: Io.Dir = .{ .handle = undefined }; |
| 3135 | var result: Dir = .{ .handle = undefined }; |
| 3134 | 3136 | try current_thread.checkCancel(); |
| 3135 | 3137 | const rc = w.ntdll.NtCreateFile( |
| 3136 | 3138 | &result.handle, |
| ... | ... | @@ -3190,7 +3192,7 @@ const MakeOpenDirAccessMaskWOptions = struct { |
| 3190 | 3192 | create_disposition: u32, |
| 3191 | 3193 | }; |
| 3192 | 3194 | |
| 3193 | | fn dirClose(userdata: ?*anyopaque, dir: Io.Dir) void { |
| 3195 | fn dirClose(userdata: ?*anyopaque, dir: Dir) void { |
| 3194 | 3196 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3195 | 3197 | _ = t; |
| 3196 | 3198 | posix.close(dir.handle); |
| ... | ... | @@ -3201,7 +3203,7 @@ const dirRealPath = switch (native_os) { |
| 3201 | 3203 | else => dirRealPathPosix, |
| 3202 | 3204 | }; |
| 3203 | 3205 | |
| 3204 | | fn dirRealPathWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, out_buffer: []u8) Io.Dir.RealPathError!usize { |
| 3206 | fn dirRealPathWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, out_buffer: []u8) Dir.RealPathError!usize { |
| 3205 | 3207 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3206 | 3208 | const w = windows; |
| 3207 | 3209 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -3237,7 +3239,7 @@ fn dirRealPathWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, |
| 3237 | 3239 | return std.unicode.wtf16LeToWtf8(out_buffer, wide_slice); |
| 3238 | 3240 | } |
| 3239 | 3241 | |
| 3240 | | fn dirRealPathPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, out_buffer: []u8) Io.Dir.RealPathError!usize { |
| 3242 | fn dirRealPathPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, out_buffer: []u8) Dir.RealPathError!usize { |
| 3241 | 3243 | if (native_os == .wasi) @compileError("unsupported operating system"); |
| 3242 | 3244 | const max_path_bytes = std.fs.max_path_bytes; |
| 3243 | 3245 | |
| ... | ... | @@ -3434,11 +3436,11 @@ const dirDeleteFile = switch (native_os) { |
| 3434 | 3436 | else => dirDeleteFilePosix, |
| 3435 | 3437 | }; |
| 3436 | 3438 | |
| 3437 | | fn dirDeleteFileWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void { |
| 3439 | fn dirDeleteFileWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void { |
| 3438 | 3440 | return dirDeleteWindows(userdata, dir, sub_path, false); |
| 3439 | 3441 | } |
| 3440 | 3442 | |
| 3441 | | fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void { |
| 3443 | fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void { |
| 3442 | 3444 | if (builtin.link_libc) return dirDeleteFilePosix(userdata, dir, sub_path); |
| 3443 | 3445 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3444 | 3446 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -3482,7 +3484,7 @@ fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) I |
| 3482 | 3484 | } |
| 3483 | 3485 | } |
| 3484 | 3486 | |
| 3485 | | fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteFileError!void { |
| 3487 | fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteFileError!void { |
| 3486 | 3488 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3487 | 3489 | const current_thread = Thread.getCurrent(t); |
| 3488 | 3490 | |
| ... | ... | @@ -3567,11 +3569,11 @@ const dirDeleteDir = switch (native_os) { |
| 3567 | 3569 | else => dirDeleteDirPosix, |
| 3568 | 3570 | }; |
| 3569 | 3571 | |
| 3570 | | fn dirDeleteDirWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void { |
| 3572 | fn dirDeleteDirWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void { |
| 3571 | 3573 | return dirDeleteWindows(userdata, dir, sub_path, true); |
| 3572 | 3574 | } |
| 3573 | 3575 | |
| 3574 | | fn dirDeleteWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, remove_dir: bool) Io.Dir.DeleteFileError!void { |
| 3576 | fn dirDeleteWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, remove_dir: bool) Dir.DeleteFileError!void { |
| 3575 | 3577 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3576 | 3578 | const current_thread = Thread.getCurrent(t); |
| 3577 | 3579 | const w = windows; |
| ... | ... | @@ -3712,7 +3714,7 @@ fn dirDeleteWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, re |
| 3712 | 3714 | } |
| 3713 | 3715 | } |
| 3714 | 3716 | |
| 3715 | | fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void { |
| 3717 | fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void { |
| 3716 | 3718 | if (builtin.link_libc) return dirDeleteDirPosix(userdata, dir, sub_path); |
| 3717 | 3719 | |
| 3718 | 3720 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -3758,7 +3760,7 @@ fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io |
| 3758 | 3760 | } |
| 3759 | 3761 | } |
| 3760 | 3762 | |
| 3761 | | fn dirDeleteDirPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8) Io.Dir.DeleteDirError!void { |
| 3763 | fn dirDeleteDirPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.DeleteDirError!void { |
| 3762 | 3764 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3763 | 3765 | const current_thread = Thread.getCurrent(t); |
| 3764 | 3766 | |
| ... | ... | @@ -3812,11 +3814,11 @@ const dirRename = switch (native_os) { |
| 3812 | 3814 | |
| 3813 | 3815 | fn dirRenameWindows( |
| 3814 | 3816 | userdata: ?*anyopaque, |
| 3815 | | old_dir: Io.Dir, |
| 3817 | old_dir: Dir, |
| 3816 | 3818 | old_sub_path: []const u8, |
| 3817 | | new_dir: Io.Dir, |
| 3819 | new_dir: Dir, |
| 3818 | 3820 | new_sub_path: []const u8, |
| 3819 | | ) Io.Dir.RenameError!void { |
| 3821 | ) Dir.RenameError!void { |
| 3820 | 3822 | const w = windows; |
| 3821 | 3823 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3822 | 3824 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -3935,11 +3937,11 @@ fn dirRenameWindows( |
| 3935 | 3937 | |
| 3936 | 3938 | fn dirRenameWasi( |
| 3937 | 3939 | userdata: ?*anyopaque, |
| 3938 | | old_dir: Io.Dir, |
| 3940 | old_dir: Dir, |
| 3939 | 3941 | old_sub_path: []const u8, |
| 3940 | | new_dir: Io.Dir, |
| 3942 | new_dir: Dir, |
| 3941 | 3943 | new_sub_path: []const u8, |
| 3942 | | ) Io.Dir.RenameError!void { |
| 3944 | ) Dir.RenameError!void { |
| 3943 | 3945 | if (builtin.link_libc) return dirRenamePosix(userdata, old_dir, old_sub_path, new_dir, new_sub_path); |
| 3944 | 3946 | |
| 3945 | 3947 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -3986,11 +3988,11 @@ fn dirRenameWasi( |
| 3986 | 3988 | |
| 3987 | 3989 | fn dirRenamePosix( |
| 3988 | 3990 | userdata: ?*anyopaque, |
| 3989 | | old_dir: Io.Dir, |
| 3991 | old_dir: Dir, |
| 3990 | 3992 | old_sub_path: []const u8, |
| 3991 | | new_dir: Io.Dir, |
| 3993 | new_dir: Dir, |
| 3992 | 3994 | new_sub_path: []const u8, |
| 3993 | | ) Io.Dir.RenameError!void { |
| 3995 | ) Dir.RenameError!void { |
| 3994 | 3996 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 3995 | 3997 | const current_thread = Thread.getCurrent(t); |
| 3996 | 3998 | |
| ... | ... | @@ -4046,11 +4048,11 @@ const dirSymLink = switch (native_os) { |
| 4046 | 4048 | |
| 4047 | 4049 | fn dirSymLinkWindows( |
| 4048 | 4050 | userdata: ?*anyopaque, |
| 4049 | | dir: Io.Dir, |
| 4051 | dir: Dir, |
| 4050 | 4052 | target_path: []const u8, |
| 4051 | 4053 | sym_link_path: []const u8, |
| 4052 | | flags: Io.Dir.SymLinkFlags, |
| 4053 | | ) Io.Dir.SymLinkError!void { |
| 4054 | flags: Dir.SymLinkFlags, |
| 4055 | ) Dir.SymLinkError!void { |
| 4054 | 4056 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4055 | 4057 | const current_thread = Thread.getCurrent(t); |
| 4056 | 4058 | const w = windows; |
| ... | ... | @@ -4161,11 +4163,11 @@ fn dirSymLinkWindows( |
| 4161 | 4163 | |
| 4162 | 4164 | fn dirSymLinkWasi( |
| 4163 | 4165 | userdata: ?*anyopaque, |
| 4164 | | dir: Io.Dir, |
| 4166 | dir: Dir, |
| 4165 | 4167 | target_path: []const u8, |
| 4166 | 4168 | sym_link_path: []const u8, |
| 4167 | | flags: Io.Dir.SymLinkFlags, |
| 4168 | | ) Io.Dir.SymLinkError!void { |
| 4169 | flags: Dir.SymLinkFlags, |
| 4170 | ) Dir.SymLinkError!void { |
| 4169 | 4171 | if (builtin.link_libc) return dirSymLinkPosix(dir, target_path, sym_link_path, flags); |
| 4170 | 4172 | |
| 4171 | 4173 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -4209,11 +4211,11 @@ fn dirSymLinkWasi( |
| 4209 | 4211 | |
| 4210 | 4212 | fn dirSymLinkPosix( |
| 4211 | 4213 | userdata: ?*anyopaque, |
| 4212 | | dir: Io.Dir, |
| 4214 | dir: Dir, |
| 4213 | 4215 | target_path: []const u8, |
| 4214 | 4216 | sym_link_path: []const u8, |
| 4215 | | flags: Io.Dir.SymLinkFlags, |
| 4216 | | ) Io.Dir.SymLinkError!void { |
| 4217 | flags: Dir.SymLinkFlags, |
| 4218 | ) Dir.SymLinkError!void { |
| 4217 | 4219 | _ = flags; |
| 4218 | 4220 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4219 | 4221 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -4264,7 +4266,7 @@ const dirReadLink = switch (native_os) { |
| 4264 | 4266 | else => dirReadLinkPosix, |
| 4265 | 4267 | }; |
| 4266 | 4268 | |
| 4267 | | fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize { |
| 4269 | fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize { |
| 4268 | 4270 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4269 | 4271 | const current_thread = Thread.getCurrent(t); |
| 4270 | 4272 | const w = windows; |
| ... | ... | @@ -4322,7 +4324,7 @@ fn dirReadLinkWindows(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, |
| 4322 | 4324 | return std.unicode.wtf16LeToWtf8(buffer, wide_result); |
| 4323 | 4325 | } |
| 4324 | 4326 | |
| 4325 | | fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize { |
| 4327 | fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize { |
| 4326 | 4328 | if (builtin.link_libc) return dirReadLinkPosix(userdata, dir, sub_path, buffer); |
| 4327 | 4329 | |
| 4328 | 4330 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -4362,7 +4364,7 @@ fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buf |
| 4362 | 4364 | } |
| 4363 | 4365 | } |
| 4364 | 4366 | |
| 4365 | | fn dirReadLinkPosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, buffer: []u8) Io.Dir.ReadLinkError!usize { |
| 4367 | fn dirReadLinkPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer: []u8) Dir.ReadLinkError!usize { |
| 4366 | 4368 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4367 | 4369 | const current_thread = Thread.getCurrent(t); |
| 4368 | 4370 | |
| ... | ... | @@ -4408,7 +4410,7 @@ const dirSetPermissions = switch (native_os) { |
| 4408 | 4410 | else => dirSetPermissionsPosix, |
| 4409 | 4411 | }; |
| 4410 | 4412 | |
| 4411 | | fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io.Dir.Permissions) Io.Dir.SetPermissionsError!void { |
| 4413 | fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void { |
| 4412 | 4414 | // TODO I think we can actually set permissions on a dir on windows? |
| 4413 | 4415 | _ = userdata; |
| 4414 | 4416 | _ = dir; |
| ... | ... | @@ -4416,7 +4418,7 @@ fn dirSetPermissionsWindows(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io. |
| 4416 | 4418 | return error.Unexpected; |
| 4417 | 4419 | } |
| 4418 | 4420 | |
| 4419 | | fn dirSetPermissionsPosix(userdata: ?*anyopaque, dir: Io.Dir, permissions: Io.Dir.Permissions) Io.Dir.SetPermissionsError!void { |
| 4421 | fn dirSetPermissionsPosix(userdata: ?*anyopaque, dir: Dir, permissions: Dir.Permissions) Dir.SetPermissionsError!void { |
| 4420 | 4422 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4421 | 4423 | const current_thread = Thread.getCurrent(t); |
| 4422 | 4424 | return setPermissionsPosix(current_thread, dir.handle, permissions.toMode()); |
| ... | ... | @@ -4427,7 +4429,7 @@ const dirSetOwner = switch (native_os) { |
| 4427 | 4429 | else => dirSetOwnerPosix, |
| 4428 | 4430 | }; |
| 4429 | 4431 | |
| 4430 | | fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.Dir.SetOwnerError!void { |
| 4432 | fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void { |
| 4431 | 4433 | _ = userdata; |
| 4432 | 4434 | _ = dir; |
| 4433 | 4435 | _ = owner; |
| ... | ... | @@ -4435,7 +4437,7 @@ fn dirSetOwnerUnsupported(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Ui |
| 4435 | 4437 | return error.Unexpected; |
| 4436 | 4438 | } |
| 4437 | 4439 | |
| 4438 | | fn dirSetOwnerPosix(userdata: ?*anyopaque, dir: Io.Dir, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.Dir.SetOwnerError!void { |
| 4440 | fn dirSetOwnerPosix(userdata: ?*anyopaque, dir: Dir, owner: ?File.Uid, group: ?File.Gid) Dir.SetOwnerError!void { |
| 4439 | 4441 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4440 | 4442 | const current_thread = Thread.getCurrent(t); |
| 4441 | 4443 | 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 |
| 4443 | 4445 | return setOwnerPosix(current_thread, dir.handle, uid, gid); |
| 4444 | 4446 | } |
| 4445 | 4447 | |
| 4446 | | fn setOwnerPosix(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid: posix.gid_t) Io.File.SetOwnerError!void { |
| 4448 | fn setOwnerPosix(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid: posix.gid_t) File.SetOwnerError!void { |
| 4447 | 4449 | try current_thread.beginSyscall(); |
| 4448 | 4450 | while (true) { |
| 4449 | 4451 | 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: |
| 4456 | 4458 | else => |e| { |
| 4457 | 4459 | current_thread.endSyscall(); |
| 4458 | 4460 | 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` |
| 4460 | 4462 | .FAULT => |err| return errnoBug(err), |
| 4461 | 4463 | .INVAL => |err| return errnoBug(err), |
| 4462 | 4464 | .ACCES => return error.AccessDenied, |
| ... | ... | @@ -4479,7 +4481,7 @@ const fileSync = switch (native_os) { |
| 4479 | 4481 | else => fileSyncPosix, |
| 4480 | 4482 | }; |
| 4481 | 4483 | |
| 4482 | | fn fileSyncWindows(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void { |
| 4484 | fn fileSyncWindows(userdata: ?*anyopaque, file: File) File.SyncError!void { |
| 4483 | 4485 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4484 | 4486 | const current_thread = Thread.getCurrent(t); |
| 4485 | 4487 | |
| ... | ... | @@ -4497,7 +4499,7 @@ fn fileSyncWindows(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void |
| 4497 | 4499 | } |
| 4498 | 4500 | } |
| 4499 | 4501 | |
| 4500 | | fn fileSyncPosix(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void { |
| 4502 | fn fileSyncPosix(userdata: ?*anyopaque, file: File) File.SyncError!void { |
| 4501 | 4503 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4502 | 4504 | const current_thread = Thread.getCurrent(t); |
| 4503 | 4505 | try current_thread.beginSyscall(); |
| ... | ... | @@ -4525,13 +4527,13 @@ fn fileSyncPosix(userdata: ?*anyopaque, file: Io.File) Io.File.SyncError!void { |
| 4525 | 4527 | } |
| 4526 | 4528 | } |
| 4527 | 4529 | |
| 4528 | | fn fileIsTty(userdata: ?*anyopaque, file: Io.File) Io.Cancelable!bool { |
| 4530 | fn fileIsTty(userdata: ?*anyopaque, file: File) Io.Cancelable!bool { |
| 4529 | 4531 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4530 | 4532 | const current_thread = Thread.getCurrent(t); |
| 4531 | 4533 | return isTty(current_thread, file); |
| 4532 | 4534 | } |
| 4533 | 4535 | |
| 4534 | | fn isTty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool { |
| 4536 | fn isTty(current_thread: *Thread, file: File) Io.Cancelable!bool { |
| 4535 | 4537 | if (is_windows) { |
| 4536 | 4538 | if (try isCygwinPty(current_thread, file)) return true; |
| 4537 | 4539 | try current_thread.checkCancel(); |
| ... | ... | @@ -4604,7 +4606,7 @@ fn isTty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool { |
| 4604 | 4606 | @compileError("unimplemented"); |
| 4605 | 4607 | } |
| 4606 | 4608 | |
| 4607 | | fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.File.EnableAnsiEscapeCodesError!void { |
| 4609 | fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: File) File.EnableAnsiEscapeCodesError!void { |
| 4608 | 4610 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4609 | 4611 | const current_thread = Thread.getCurrent(t); |
| 4610 | 4612 | |
| ... | ... | @@ -4639,13 +4641,13 @@ fn fileEnableAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.File.Enabl |
| 4639 | 4641 | return error.NotTerminalDevice; |
| 4640 | 4642 | } |
| 4641 | 4643 | |
| 4642 | | fn fileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: Io.File) Io.Cancelable!bool { |
| 4644 | fn fileSupportsAnsiEscapeCodes(userdata: ?*anyopaque, file: File) Io.Cancelable!bool { |
| 4643 | 4645 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4644 | 4646 | const current_thread = Thread.getCurrent(t); |
| 4645 | 4647 | return supportsAnsiEscapeCodes(current_thread, file); |
| 4646 | 4648 | } |
| 4647 | 4649 | |
| 4648 | | fn supportsAnsiEscapeCodes(current_thread: *Thread, file: Io.File) Io.Cancelable!bool { |
| 4650 | fn supportsAnsiEscapeCodes(current_thread: *Thread, file: File) Io.Cancelable!bool { |
| 4649 | 4651 | if (is_windows) { |
| 4650 | 4652 | try current_thread.checkCancel(); |
| 4651 | 4653 | var console_mode: windows.DWORD = 0; |
| ... | ... | @@ -4667,7 +4669,7 @@ fn supportsAnsiEscapeCodes(current_thread: *Thread, file: Io.File) Io.Cancelable |
| 4667 | 4669 | return false; |
| 4668 | 4670 | } |
| 4669 | 4671 | |
| 4670 | | fn isCygwinPty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool { |
| 4672 | fn isCygwinPty(current_thread: *Thread, file: File) Io.Cancelable!bool { |
| 4671 | 4673 | if (!is_windows) return false; |
| 4672 | 4674 | |
| 4673 | 4675 | const handle = file.handle; |
| ... | ... | @@ -4721,7 +4723,7 @@ fn isCygwinPty(current_thread: *Thread, file: Io.File) Io.Cancelable!bool { |
| 4721 | 4723 | std.mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null; |
| 4722 | 4724 | } |
| 4723 | 4725 | |
| 4724 | | fn fileSetLength(userdata: ?*anyopaque, file: Io.File, length: u64) Io.File.SetLengthError!void { |
| 4726 | fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthError!void { |
| 4725 | 4727 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4726 | 4728 | const current_thread = Thread.getCurrent(t); |
| 4727 | 4729 | |
| ... | ... | @@ -4805,7 +4807,7 @@ fn fileSetLength(userdata: ?*anyopaque, file: Io.File, length: u64) Io.File.SetL |
| 4805 | 4807 | } |
| 4806 | 4808 | } |
| 4807 | 4809 | |
| 4808 | | fn fileSetOwner(userdata: ?*anyopaque, file: Io.File, owner: ?Io.File.Uid, group: ?Io.File.Gid) Io.File.SetOwnerError!void { |
| 4810 | fn fileSetOwner(userdata: ?*anyopaque, file: File, owner: ?File.Uid, group: ?File.Gid) File.SetOwnerError!void { |
| 4809 | 4811 | switch (native_os) { |
| 4810 | 4812 | .windows, .wasi => return error.Unexpected, |
| 4811 | 4813 | else => {}, |
| ... | ... | @@ -4817,7 +4819,7 @@ fn fileSetOwner(userdata: ?*anyopaque, file: Io.File, owner: ?Io.File.Uid, group |
| 4817 | 4819 | return setOwnerPosix(current_thread, file.handle, uid, gid); |
| 4818 | 4820 | } |
| 4819 | 4821 | |
| 4820 | | fn fileSetPermissions(userdata: ?*anyopaque, file: Io.File, permissions: Io.File.Permissions) Io.File.SetPermissionsError!void { |
| 4822 | fn fileSetPermissions(userdata: ?*anyopaque, file: File, permissions: File.Permissions) File.SetPermissionsError!void { |
| 4821 | 4823 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4822 | 4824 | const current_thread = Thread.getCurrent(t); |
| 4823 | 4825 | switch (native_os) { |
| ... | ... | @@ -4850,7 +4852,7 @@ fn fileSetPermissions(userdata: ?*anyopaque, file: Io.File, permissions: Io.File |
| 4850 | 4852 | } |
| 4851 | 4853 | } |
| 4852 | 4854 | |
| 4853 | | fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode_t) Io.File.SetPermissionsError!void { |
| 4855 | fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode_t) File.SetPermissionsError!void { |
| 4854 | 4856 | try current_thread.beginSyscall(); |
| 4855 | 4857 | while (true) { |
| 4856 | 4858 | switch (posix.errno(posix.system.fchmod(fd, mode))) { |
| ... | ... | @@ -4883,12 +4885,12 @@ fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode |
| 4883 | 4885 | |
| 4884 | 4886 | fn dirSetTimestamps( |
| 4885 | 4887 | userdata: ?*anyopaque, |
| 4886 | | dir: Io.Dir, |
| 4888 | dir: Dir, |
| 4887 | 4889 | sub_path: []const u8, |
| 4888 | 4890 | last_accessed: Io.Timestamp, |
| 4889 | 4891 | last_modified: Io.Timestamp, |
| 4890 | | options: Io.File.SetTimestampsOptions, |
| 4891 | | ) Io.File.SetTimestampsError!void { |
| 4892 | options: File.SetTimestampsOptions, |
| 4893 | ) File.SetTimestampsError!void { |
| 4892 | 4894 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4893 | 4895 | const current_thread = Thread.getCurrent(t); |
| 4894 | 4896 | |
| ... | ... | @@ -4937,10 +4939,10 @@ fn dirSetTimestamps( |
| 4937 | 4939 | |
| 4938 | 4940 | fn dirSetTimestampsNow( |
| 4939 | 4941 | userdata: ?*anyopaque, |
| 4940 | | dir: Io.Dir, |
| 4942 | dir: Dir, |
| 4941 | 4943 | sub_path: []const u8, |
| 4942 | | options: Io.File.SetTimestampsOptions, |
| 4943 | | ) Io.File.SetTimestampsError!void { |
| 4944 | options: File.SetTimestampsOptions, |
| 4945 | ) File.SetTimestampsError!void { |
| 4944 | 4946 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4945 | 4947 | const current_thread = Thread.getCurrent(t); |
| 4946 | 4948 | |
| ... | ... | @@ -4984,10 +4986,10 @@ fn dirSetTimestampsNow( |
| 4984 | 4986 | |
| 4985 | 4987 | fn fileSetTimestamps( |
| 4986 | 4988 | userdata: ?*anyopaque, |
| 4987 | | file: Io.File, |
| 4989 | file: File, |
| 4988 | 4990 | last_accessed: Io.Timestamp, |
| 4989 | 4991 | last_modified: Io.Timestamp, |
| 4990 | | ) Io.File.SetTimestampsError!void { |
| 4992 | ) File.SetTimestampsError!void { |
| 4991 | 4993 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4992 | 4994 | const current_thread = Thread.getCurrent(t); |
| 4993 | 4995 | |
| ... | ... | @@ -5068,7 +5070,7 @@ fn fileSetTimestamps( |
| 5068 | 5070 | } |
| 5069 | 5071 | } |
| 5070 | 5072 | |
| 5071 | | fn fileSetTimestampsNow(userdata: ?*anyopaque, file: Io.File) Io.File.SetTimestampsError!void { |
| 5073 | fn fileSetTimestampsNow(userdata: ?*anyopaque, file: File) File.SetTimestampsError!void { |
| 5072 | 5074 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5073 | 5075 | const current_thread = Thread.getCurrent(t); |
| 5074 | 5076 | |
| ... | ... | @@ -5133,7 +5135,7 @@ fn fileSetTimestampsNow(userdata: ?*anyopaque, file: Io.File) Io.File.SetTimesta |
| 5133 | 5135 | const windows_lock_range_off: windows.LARGE_INTEGER = 0; |
| 5134 | 5136 | const windows_lock_range_len: windows.LARGE_INTEGER = 1; |
| 5135 | 5137 | |
| 5136 | | fn fileLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.LockError!void { |
| 5138 | fn fileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!void { |
| 5137 | 5139 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5138 | 5140 | const current_thread = Thread.getCurrent(t); |
| 5139 | 5141 | |
| ... | ... | @@ -5195,7 +5197,7 @@ fn fileLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.Lo |
| 5195 | 5197 | } |
| 5196 | 5198 | } |
| 5197 | 5199 | |
| 5198 | | fn fileTryLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File.LockError!bool { |
| 5200 | fn fileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!bool { |
| 5199 | 5201 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5200 | 5202 | const current_thread = Thread.getCurrent(t); |
| 5201 | 5203 | |
| ... | ... | @@ -5263,7 +5265,7 @@ fn fileTryLock(userdata: ?*anyopaque, file: Io.File, lock: Io.File.Lock) Io.File |
| 5263 | 5265 | } |
| 5264 | 5266 | } |
| 5265 | 5267 | |
| 5266 | | fn fileUnlock(userdata: ?*anyopaque, file: Io.File) void { |
| 5268 | fn fileUnlock(userdata: ?*anyopaque, file: File) void { |
| 5267 | 5269 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5268 | 5270 | const current_thread = Thread.getCurrent(t); |
| 5269 | 5271 | |
| ... | ... | @@ -5311,7 +5313,7 @@ fn fileUnlock(userdata: ?*anyopaque, file: Io.File) void { |
| 5311 | 5313 | } |
| 5312 | 5314 | } |
| 5313 | 5315 | |
| 5314 | | fn fileDowngradeLock(userdata: ?*anyopaque, file: Io.File) Io.File.DowngradeLockError!void { |
| 5316 | fn fileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!void { |
| 5315 | 5317 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5316 | 5318 | const current_thread = Thread.getCurrent(t); |
| 5317 | 5319 | |
| ... | ... | @@ -5388,10 +5390,10 @@ fn fileDowngradeLock(userdata: ?*anyopaque, file: Io.File) Io.File.DowngradeLock |
| 5388 | 5390 | |
| 5389 | 5391 | fn dirOpenDirWasi( |
| 5390 | 5392 | userdata: ?*anyopaque, |
| 5391 | | dir: Io.Dir, |
| 5393 | dir: Dir, |
| 5392 | 5394 | sub_path: []const u8, |
| 5393 | | options: Io.Dir.OpenOptions, |
| 5394 | | ) Io.Dir.OpenError!Io.Dir { |
| 5395 | options: Dir.OpenOptions, |
| 5396 | ) Dir.OpenError!Dir { |
| 5395 | 5397 | if (builtin.link_libc) return dirOpenDirPosix(userdata, dir, sub_path, options); |
| 5396 | 5398 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5397 | 5399 | const current_thread = Thread.getCurrent(t); |
| ... | ... | @@ -5462,7 +5464,7 @@ fn dirOpenDirWasi( |
| 5462 | 5464 | } |
| 5463 | 5465 | } |
| 5464 | 5466 | |
| 5465 | | fn fileClose(userdata: ?*anyopaque, file: Io.File) void { |
| 5467 | fn fileClose(userdata: ?*anyopaque, file: File) void { |
| 5466 | 5468 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5467 | 5469 | _ = t; |
| 5468 | 5470 | posix.close(file.handle); |
| ... | ... | @@ -5473,7 +5475,7 @@ const fileReadStreaming = switch (native_os) { |
| 5473 | 5475 | else => fileReadStreamingPosix, |
| 5474 | 5476 | }; |
| 5475 | 5477 | |
| 5476 | | fn fileReadStreamingPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File.Reader.Error!usize { |
| 5478 | fn fileReadStreamingPosix(userdata: ?*anyopaque, file: File, data: [][]u8) File.Reader.Error!usize { |
| 5477 | 5479 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5478 | 5480 | const current_thread = Thread.getCurrent(t); |
| 5479 | 5481 | |
| ... | ... | @@ -5562,7 +5564,7 @@ fn fileReadStreamingPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io |
| 5562 | 5564 | } |
| 5563 | 5565 | } |
| 5564 | 5566 | |
| 5565 | | fn fileReadStreamingWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File.Reader.Error!usize { |
| 5567 | fn fileReadStreamingWindows(userdata: ?*anyopaque, file: File, data: [][]u8) File.Reader.Error!usize { |
| 5566 | 5568 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5567 | 5569 | const current_thread = Thread.getCurrent(t); |
| 5568 | 5570 | |
| ... | ... | @@ -5591,7 +5593,7 @@ fn fileReadStreamingWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8) |
| 5591 | 5593 | } |
| 5592 | 5594 | } |
| 5593 | 5595 | |
| 5594 | | fn fileReadPositionalPosix(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset: u64) Io.File.ReadPositionalError!usize { |
| 5596 | fn fileReadPositionalPosix(userdata: ?*anyopaque, file: File, data: [][]u8, offset: u64) File.ReadPositionalError!usize { |
| 5595 | 5597 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5596 | 5598 | const current_thread = Thread.getCurrent(t); |
| 5597 | 5599 | |
| ... | ... | @@ -5694,7 +5696,7 @@ const fileReadPositional = switch (native_os) { |
| 5694 | 5696 | else => fileReadPositionalPosix, |
| 5695 | 5697 | }; |
| 5696 | 5698 | |
| 5697 | | fn fileReadPositionalWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset: u64) Io.File.ReadPositionalError!usize { |
| 5699 | fn fileReadPositionalWindows(userdata: ?*anyopaque, file: File, data: [][]u8, offset: u64) File.ReadPositionalError!usize { |
| 5698 | 5700 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5699 | 5701 | const current_thread = Thread.getCurrent(t); |
| 5700 | 5702 | |
| ... | ... | @@ -5736,7 +5738,7 @@ fn fileReadPositionalWindows(userdata: ?*anyopaque, file: Io.File, data: [][]u8, |
| 5736 | 5738 | } |
| 5737 | 5739 | } |
| 5738 | 5740 | |
| 5739 | | fn fileSeekBy(userdata: ?*anyopaque, file: Io.File, offset: i64) Io.File.SeekError!void { |
| 5741 | fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!void { |
| 5740 | 5742 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5741 | 5743 | const current_thread = Thread.getCurrent(t); |
| 5742 | 5744 | const fd = file.handle; |
| ... | ... | @@ -5834,7 +5836,7 @@ fn fileSeekBy(userdata: ?*anyopaque, file: Io.File, offset: i64) Io.File.SeekErr |
| 5834 | 5836 | } |
| 5835 | 5837 | } |
| 5836 | 5838 | |
| 5837 | | fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekError!void { |
| 5839 | fn fileSeekTo(userdata: ?*anyopaque, file: File, offset: u64) File.SeekError!void { |
| 5838 | 5840 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5839 | 5841 | const current_thread = Thread.getCurrent(t); |
| 5840 | 5842 | const fd = file.handle; |
| ... | ... | @@ -5930,7 +5932,7 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr |
| 5930 | 5932 | } |
| 5931 | 5933 | } |
| 5932 | 5934 | |
| 5933 | | fn openSelfExe(userdata: ?*anyopaque, flags: Io.File.OpenFlags) Io.File.OpenSelfExeError!Io.File { |
| 5935 | fn openSelfExe(userdata: ?*anyopaque, flags: File.OpenFlags) File.OpenSelfExeError!File { |
| 5934 | 5936 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5935 | 5937 | switch (native_os) { |
| 5936 | 5938 | .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 |
| 5949 | 5951 | |
| 5950 | 5952 | fn fileWritePositional( |
| 5951 | 5953 | userdata: ?*anyopaque, |
| 5952 | | file: Io.File, |
| 5954 | file: File, |
| 5953 | 5955 | header: []const u8, |
| 5954 | 5956 | data: []const []const u8, |
| 5955 | 5957 | splat: usize, |
| 5956 | 5958 | offset: u64, |
| 5957 | | ) Io.File.WritePositionalError!usize { |
| 5959 | ) File.WritePositionalError!usize { |
| 5958 | 5960 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 5959 | 5961 | const current_thread = Thread.getCurrent(t); |
| 5960 | 5962 | |
| ... | ... | @@ -6071,11 +6073,11 @@ fn fileWritePositional( |
| 6071 | 6073 | |
| 6072 | 6074 | fn fileWriteStreaming( |
| 6073 | 6075 | userdata: ?*anyopaque, |
| 6074 | | file: Io.File, |
| 6076 | file: File, |
| 6075 | 6077 | header: []const u8, |
| 6076 | 6078 | data: []const []const u8, |
| 6077 | 6079 | splat: usize, |
| 6078 | | ) Io.File.WriteStreamingError!usize { |
| 6080 | ) File.WriteStreamingError!usize { |
| 6079 | 6081 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 6080 | 6082 | const current_thread = Thread.getCurrent(t); |
| 6081 | 6083 | |
| ... | ... | @@ -6187,11 +6189,11 @@ fn fileWriteStreaming( |
| 6187 | 6189 | |
| 6188 | 6190 | fn fileWriteFileStreaming( |
| 6189 | 6191 | userdata: ?*anyopaque, |
| 6190 | | file: Io.File, |
| 6192 | file: File, |
| 6191 | 6193 | header: []const u8, |
| 6192 | | file_reader: *Io.File.Reader, |
| 6194 | file_reader: *File.Reader, |
| 6193 | 6195 | limit: Io.Limit, |
| 6194 | | ) Io.File.WriteFileStreamingError!usize { |
| 6196 | ) File.WriteFileStreamingError!usize { |
| 6195 | 6197 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 6196 | 6198 | const reader_buffered = file_reader.interface.buffered(); |
| 6197 | 6199 | if (reader_buffered.len >= @intFromEnum(limit)) { |
| ... | ... | @@ -6585,7 +6587,7 @@ fn netWriteFile( |
| 6585 | 6587 | userdata: ?*anyopaque, |
| 6586 | 6588 | socket_handle: net.Socket.Handle, |
| 6587 | 6589 | header: []const u8, |
| 6588 | | file_reader: *Io.File.Reader, |
| 6590 | file_reader: *File.Reader, |
| 6589 | 6591 | limit: Io.Limit, |
| 6590 | 6592 | ) net.Stream.WriteFileError!usize { |
| 6591 | 6593 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| ... | ... | @@ -6599,12 +6601,12 @@ fn netWriteFile( |
| 6599 | 6601 | |
| 6600 | 6602 | fn fileWriteFilePositional( |
| 6601 | 6603 | userdata: ?*anyopaque, |
| 6602 | | file: Io.File, |
| 6604 | file: File, |
| 6603 | 6605 | header: []const u8, |
| 6604 | | file_reader: *Io.File.Reader, |
| 6606 | file_reader: *File.Reader, |
| 6605 | 6607 | limit: Io.Limit, |
| 6606 | 6608 | offset: u64, |
| 6607 | | ) Io.File.WriteFilePositionalError!usize { |
| 6609 | ) File.WriteFilePositionalError!usize { |
| 6608 | 6610 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 6609 | 6611 | const reader_buffered = file_reader.interface.buffered(); |
| 6610 | 6612 | if (reader_buffered.len >= @intFromEnum(limit)) { |
| ... | ... | @@ -9488,7 +9490,7 @@ fn clockToWasi(clock: Io.Clock) std.os.wasi.clockid_t { |
| 9488 | 9490 | }; |
| 9489 | 9491 | } |
| 9490 | 9492 | |
| 9491 | | fn statFromLinux(stx: *const std.os.linux.Statx) Io.File.Stat { |
| 9493 | fn statFromLinux(stx: *const std.os.linux.Statx) File.Stat { |
| 9492 | 9494 | const atime = stx.atime; |
| 9493 | 9495 | const mtime = stx.mtime; |
| 9494 | 9496 | const ctime = stx.ctime; |
| ... | ... | @@ -9512,7 +9514,7 @@ fn statFromLinux(stx: *const std.os.linux.Statx) Io.File.Stat { |
| 9512 | 9514 | }; |
| 9513 | 9515 | } |
| 9514 | 9516 | |
| 9515 | | fn statFromPosix(st: *const posix.Stat) Io.File.Stat { |
| 9517 | fn statFromPosix(st: *const posix.Stat) File.Stat { |
| 9516 | 9518 | const atime = st.atime(); |
| 9517 | 9519 | const mtime = st.mtime(); |
| 9518 | 9520 | const ctime = st.ctime(); |
| ... | ... | @@ -9546,7 +9548,7 @@ fn statFromPosix(st: *const posix.Stat) Io.File.Stat { |
| 9546 | 9548 | }; |
| 9547 | 9549 | } |
| 9548 | 9550 | |
| 9549 | | fn statFromWasi(st: *const std.os.wasi.filestat_t) Io.File.Stat { |
| 9551 | fn statFromWasi(st: *const std.os.wasi.filestat_t) File.Stat { |
| 9550 | 9552 | return .{ |
| 9551 | 9553 | .inode = st.ino, |
| 9552 | 9554 | .size = @bitCast(st.size), |
| ... | ... | @@ -9577,7 +9579,7 @@ fn timestampToPosix(nanoseconds: i96) posix.timespec { |
| 9577 | 9579 | }; |
| 9578 | 9580 | } |
| 9579 | 9581 | |
| 9580 | | fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Io.Dir.PathNameError![:0]u8 { |
| 9582 | fn pathToPosix(file_path: []const u8, buffer: *[posix.PATH_MAX]u8) Dir.PathNameError![:0]u8 { |
| 9581 | 9583 | if (std.mem.containsAtLeastScalar2(u8, file_path, 0, 1)) return error.BadPathName; |
| 9582 | 9584 | // >= rather than > to make room for the null byte |
| 9583 | 9585 | if (file_path.len >= buffer.len) return error.NameTooLong; |
| ... | ... | @@ -9824,7 +9826,7 @@ fn lookupHosts( |
| 9824 | 9826 | options: HostName.LookupOptions, |
| 9825 | 9827 | ) !void { |
| 9826 | 9828 | 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) { |
| 9828 | 9830 | error.FileNotFound, |
| 9829 | 9831 | error.NotDir, |
| 9830 | 9832 | error.AccessDenied, |