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