authorgravatar for infos.g.infos@gmail.comgDator <infos.g.infos@gmail.com> 2026-07-23 23:06:12+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-07-23 23:06:12+02:00
log8b2d0ce218db8d874cec1c11b3f186955af620c1
tree666ff2c4dd947784c6fd28d9e9a605e7cad53e46
parent6aff551f179c40563e00073792517562d5132b1a

Io.Threaded: Implement fileLength without fileStat on Windows (#36293)

Closes #36179 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36293 Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>

1 files changed, 20 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+20-1
......@@ -3858,7 +3858,26 @@ fn fileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 {
38583858 }
38593859 }
38603860 } else if (is_windows) {
3861 // TODO call NtQueryInformationFile and ask for only the size instead of "all"
3861 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
3862 var info: windows.FILE.STANDARD_INFORMATION = undefined;
3863 const syscall: Syscall = try .start();
3864 while (true) switch (windows.ntdll.NtQueryInformationFile(
3865 file.handle,
3866 &io_status_block,
3867 &info,
3868 @sizeOf(windows.FILE.STANDARD_INFORMATION),
3869 .Standard,
3870 )) {
3871 .SUCCESS => break syscall.finish(),
3872 .INVALID_PARAMETER => |err| return syscall.ntstatusBug(err),
3873 .ACCESS_DENIED => return syscall.fail(error.AccessDenied),
3874 .CANCELLED => {
3875 try syscall.checkCancel();
3876 continue;
3877 },
3878 else => |s| return syscall.unexpectedNtstatus(s),
3879 };
3880 return @as(u64, @bitCast(info.EndOfFile));
38623881 }
38633882
38643883 const stat = try fileStat(t, file);