aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Io/Dir.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-18 11:31:23 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:10 -0800
commit446c145ca86b014d6743f5666e9ee1d671b56045 (patch)
tree28b3754371c40a106896916e7e01a5401d9148aa /lib/std/Io/Dir.zig
parenta2416c685a83788780fec1c379008a2d795f7bd2 (diff)
downloadzig-446c145ca86b014d6743f5666e9ee1d671b56045.tar.gz
zig-446c145ca86b014d6743f5666e9ee1d671b56045.zip
std.Io.Threaded: fix compilation errors on posix
Diffstat (limited to 'lib/std/Io/Dir.zig')
-rw-r--r--lib/std/Io/Dir.zig15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig
index 970cddc82e..0bdaf369c1 100644
--- a/lib/std/Io/Dir.zig
+++ b/lib/std/Io/Dir.zig
@@ -101,10 +101,8 @@ pub const Reader = struct {
/// Fill position of `buffer`.
end: usize,
- pub const min_buffer_len = switch (native_os) {
- .windows => std.mem.alignForward(usize, max_name_bytes, @alignOf(usize)),
- else => 32, // TODO: what is this based on?
- };
+ /// A length for `buffer` that allows all implementations to function.
+ pub const min_buffer_len = std.mem.alignForward(usize, max_name_bytes, @alignOf(usize));
pub const State = enum {
/// Indicates the next call to `read` should rewind and start over the
@@ -120,6 +118,7 @@ pub const Reader = struct {
SystemResources,
} || Io.UnexpectedError || Io.Cancelable;
+ /// Asserts that `buffer` has length at least `min_buffer_len`.
pub fn init(dir: Dir, buffer: []align(@alignOf(usize)) u8) Reader {
assert(buffer.len >= min_buffer_len);
return .{
@@ -164,7 +163,13 @@ pub const Reader = struct {
/// see `Walker`.
pub const Iterator = struct {
reader: Reader,
- reader_buffer: [2048]u8 align(@alignOf(usize)),
+ reader_buffer: [reader_buffer_len]u8 align(@alignOf(usize)),
+
+ pub const reader_buffer_len = 2048;
+
+ comptime {
+ assert(reader_buffer_len >= Reader.min_buffer_len);
+ }
pub const Error = Reader.Error;