| ... | @@ -3858,7 +3858,26 @@ fn fileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 { | ... | @@ -3858,7 +3858,26 @@ fn fileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 { |
| 3858 | } | 3858 | } |
| 3859 | } | 3859 | } |
| 3860 | } else if (is_windows) { | 3860 | } 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)); |
| 3862 | } | 3881 | } |
| 3863 | | 3882 | |
| 3864 | const stat = try fileStat(t, file); | 3883 | const stat = try fileStat(t, file); |