mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Io.Threaded: implement dirStatPath for Windows
This commit is contained in:
parent
f98352eecf
commit
482343f2e2
2 changed files with 16 additions and 6 deletions
|
|
@ -171,7 +171,7 @@ pub fn io(t: *Threaded) Io {
|
||||||
.dirStat = dirStat,
|
.dirStat = dirStat,
|
||||||
.dirStatPath = switch (builtin.os.tag) {
|
.dirStatPath = switch (builtin.os.tag) {
|
||||||
.linux => dirStatPathLinux,
|
.linux => dirStatPathLinux,
|
||||||
.windows => @panic("TODO"),
|
.windows => dirStatPathWindows,
|
||||||
.wasi => dirStatPathWasi,
|
.wasi => dirStatPathWasi,
|
||||||
else => dirStatPathPosix,
|
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(
|
fn dirStatPathWasi(
|
||||||
userdata: ?*anyopaque,
|
userdata: ?*anyopaque,
|
||||||
dir: Io.Dir,
|
dir: Io.Dir,
|
||||||
|
|
|
||||||
|
|
@ -2332,11 +2332,6 @@ pub const StatFileError = File.OpenError || File.StatError || posix.FStatAtError
|
||||||
|
|
||||||
/// Deprecated in favor of `Io.Dir.statPath`.
|
/// Deprecated in favor of `Io.Dir.statPath`.
|
||||||
pub fn statFile(self: Dir, sub_path: []const u8) StatFileError!Stat {
|
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;
|
var threaded: Io.Threaded = .init_single_threaded;
|
||||||
const io = threaded.io();
|
const io = threaded.io();
|
||||||
return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{});
|
return Io.Dir.statPath(.{ .handle = self.fd }, io, sub_path, .{});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue