diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-10-19 20:48:24 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-10-29 06:20:50 -0700 |
| commit | 482343f2e253f2078627e696fb98ff0e1d8e82df (patch) | |
| tree | 6a4ef044f123ba087a5dc683e6e48d2a8279e6e2 /lib/std | |
| parent | f98352eecf1db704b0e59ced1c6741734c3990ac (diff) | |
| download | zig-482343f2e253f2078627e696fb98ff0e1d8e82df.tar.gz zig-482343f2e253f2078627e696fb98ff0e1d8e82df.zip | |
std.Io.Threaded: implement dirStatPath for Windows
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Io/Threaded.zig | 17 | ||||
| -rw-r--r-- | lib/std/fs/Dir.zig | 5 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index d851ce30fe..4f2fe5e7b1 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -171,7 +171,7 @@ pub fn io(t: *Threaded) Io { .dirStat = dirStat, .dirStatPath = switch (builtin.os.tag) { .linux => dirStatPathLinux, - .windows => @panic("TODO"), + .windows => dirStatPathWindows, .wasi => dirStatPathWasi, else => dirStatPathPosix, }, @@ -1079,6 +1079,21 @@ fn dirStatPathPosix( } } +fn dirStatPathWindows( + userdata: ?*anyopaque, + dir: Io.Dir, + sub_path: []const u8, + options: Io.Dir.StatPathOptions, +) Io.Dir.StatPathError!Io.File.Stat { + const t: *Threaded = @ptrCast(@alignCast(userdata)); + const t_io = t.io(); + var file = try dir.openFile(t_io, sub_path, .{ + .follow_symlinks = options.follow_symlinks, + }); + defer file.close(t_io); + return file.stat(t_io); +} + fn dirStatPathWasi( userdata: ?*anyopaque, dir: Io.Dir, diff --git a/lib/std/fs/Dir.zig b/lib/std/fs/Dir.zig index aa1180a90d..2eb85928f6 100644 --- a/lib/std/fs/Dir.zig +++ b/lib/std/fs/Dir.zig @@ -2332,11 +2332,6 @@ pub const StatFileError = File.OpenError || File.StatError || posix.FStatAtError /// Deprecated in favor of `Io.Dir.statPath`. pub fn statFile(self: Dir, sub_path: []const u8) StatFileError!Stat { - if (native_os == .windows) { - var file = try self.openFile(sub_path, .{}); - defer file.close(); - return file.stat(); - } var threaded: Io.Threaded = .init_single_threaded; const io = threaded.io(); return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{}); |
