authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-19 20:48:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:50-07:00
log482343f2e253f2078627e696fb98ff0e1d8e82df
tree6a4ef044f123ba087a5dc683e6e48d2a8279e6e2
parentf98352eecf1db704b0e59ced1c6741734c3990ac

std.Io.Threaded: implement dirStatPath for Windows


2 files changed, 16 insertions(+), 6 deletions(-)

lib/std/Io/Threaded.zig+16-1
......@@ -171,7 +171,7 @@ pub fn io(t: *Threaded) Io {
171171 .dirStat = dirStat,
172172 .dirStatPath = switch (builtin.os.tag) {
173173 .linux => dirStatPathLinux,
174 .windows => @panic("TODO"),
174 .windows => dirStatPathWindows,
175175 .wasi => dirStatPathWasi,
176176 else => dirStatPathPosix,
177177 },
......@@ -1079,6 +1079,21 @@ fn dirStatPathPosix(
10791079 }
10801080}
10811081
1082fn dirStatPathWindows(
1083 userdata: ?*anyopaque,
1084 dir: Io.Dir,
1085 sub_path: []const u8,
1086 options: Io.Dir.StatPathOptions,
1087) Io.Dir.StatPathError!Io.File.Stat {
1088 const t: *Threaded = @ptrCast(@alignCast(userdata));
1089 const t_io = t.io();
1090 var file = try dir.openFile(t_io, sub_path, .{
1091 .follow_symlinks = options.follow_symlinks,
1092 });
1093 defer file.close(t_io);
1094 return file.stat(t_io);
1095}
1096
10821097fn dirStatPathWasi(
10831098 userdata: ?*anyopaque,
10841099 dir: Io.Dir,
lib/std/fs/Dir.zig-5
......@@ -2332,11 +2332,6 @@ pub const StatFileError = File.OpenError || File.StatError || posix.FStatAtError
23322332
23332333/// Deprecated in favor of `Io.Dir.statPath`.
23342334pub fn statFile(self: Dir, sub_path: []const u8) StatFileError!Stat {
2335 if (native_os == .windows) {
2336 var file = try self.openFile(sub_path, .{});
2337 defer file.close();
2338 return file.stat();
2339 }
23402335 var threaded: Io.Threaded = .init_single_threaded;
23412336 const io = threaded.io();
23422337 return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{});