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 {...@@ -171,7 +171,7 @@ pub fn io(t: *Threaded) Io {
171 .dirStat = dirStat,171 .dirStat = dirStat,
172 .dirStatPath = switch (builtin.os.tag) {172 .dirStatPath = switch (builtin.os.tag) {
173 .linux => dirStatPathLinux,173 .linux => dirStatPathLinux,
174 .windows => @panic("TODO"),174 .windows => dirStatPathWindows,
175 .wasi => dirStatPathWasi,175 .wasi => dirStatPathWasi,
176 else => dirStatPathPosix,176 else => dirStatPathPosix,
177 },177 },
...@@ -1079,6 +1079,21 @@ fn dirStatPathPosix(...@@ -1079,6 +1079,21 @@ fn dirStatPathPosix(
1079 }1079 }
1080}1080}
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
1082fn dirStatPathWasi(1097fn dirStatPathWasi(
1083 userdata: ?*anyopaque,1098 userdata: ?*anyopaque,
1084 dir: Io.Dir,1099 dir: Io.Dir,
lib/std/fs/Dir.zig-5
...@@ -2332,11 +2332,6 @@ pub const StatFileError = File.OpenError || File.StatError || posix.FStatAtError...@@ -2332,11 +2332,6 @@ pub const StatFileError = File.OpenError || File.StatError || posix.FStatAtError
23322332
2333/// Deprecated in favor of `Io.Dir.statPath`.2333/// Deprecated in favor of `Io.Dir.statPath`.
2334pub fn statFile(self: Dir, sub_path: []const u8) StatFileError!Stat {2334pub 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 }
2340 var threaded: Io.Threaded = .init_single_threaded;2335 var threaded: Io.Threaded = .init_single_threaded;
2341 const io = threaded.io();2336 const io = threaded.io();
2342 return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{});2337 return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{});