authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-18 11:31:23-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:10-08:00
log446c145ca86b014d6743f5666e9ee1d671b56045
tree28b3754371c40a106896916e7e01a5401d9148aa
parenta2416c685a83788780fec1c379008a2d795f7bd2

std.Io.Threaded: fix compilation errors on posix


2 files changed, 12 insertions(+), 7 deletions(-)

lib/std/Io/Dir.zig+10-5
......@@ -101,10 +101,8 @@ pub const Reader = struct {
101101 /// Fill position of `buffer`.
102102 end: usize,
103103
104 pub const min_buffer_len = switch (native_os) {
105 .windows => std.mem.alignForward(usize, max_name_bytes, @alignOf(usize)),
106 else => 32, // TODO: what is this based on?
107 };
104 /// A length for `buffer` that allows all implementations to function.
105 pub const min_buffer_len = std.mem.alignForward(usize, max_name_bytes, @alignOf(usize));
108106
109107 pub const State = enum {
110108 /// Indicates the next call to `read` should rewind and start over the
......@@ -120,6 +118,7 @@ pub const Reader = struct {
120118 SystemResources,
121119 } || Io.UnexpectedError || Io.Cancelable;
122120
121 /// Asserts that `buffer` has length at least `min_buffer_len`.
123122 pub fn init(dir: Dir, buffer: []align(@alignOf(usize)) u8) Reader {
124123 assert(buffer.len >= min_buffer_len);
125124 return .{
......@@ -164,7 +163,13 @@ pub const Reader = struct {
164163/// see `Walker`.
165164pub const Iterator = struct {
166165 reader: Reader,
167 reader_buffer: [2048]u8 align(@alignOf(usize)),
166 reader_buffer: [reader_buffer_len]u8 align(@alignOf(usize)),
167
168 pub const reader_buffer_len = 2048;
169
170 comptime {
171 assert(reader_buffer_len >= Reader.min_buffer_len);
172 }
168173
169174 pub const Error = Reader.Error;
170175
lib/std/Io/Threaded.zig+2-2
......@@ -1621,7 +1621,7 @@ fn dirMakePath(
16211621 // stat the file and return an error if it's not a directory
16221622 // this is important because otherwise a dangling symlink
16231623 // could cause an infinite loop
1624 const fstat = dirStatFile(t, dir, component.path, .{});
1624 const fstat = try dirStatFile(t, dir, component.path, .{});
16251625 if (fstat.kind != .directory) return error.NotDir;
16261626 },
16271627 error.FileNotFound => |e| {
......@@ -3796,7 +3796,7 @@ fn dirReadWindows(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
37963796 // the remaining unprocessed entries, then backtrack and return what we have so far.
37973797 if (name_index + std.unicode.calcWtf8Len(name_wtf16le) > unreserved_start + dr.index) {
37983798 // We should always be able to fit at least one entry into the buffer no matter what
3799 std.debug.assert(buffer_index != 0);
3799 assert(buffer_index != 0);
38003800 dr.index = backtrack_index;
38013801 break;
38023802 }