fix: Pipe size on windows.

This commit is contained in:
Rohan Jadav
2025-04-27 01:58:37 +05:30
committed by GitHub
parent 6c1a3c4f0c
commit 80a6f8928a
+6 -1
View File
@@ -506,10 +506,15 @@ _write_at :: proc(f: ^File_Impl, p: []byte, offset: i64) -> (n: i64, err: Error)
_file_size :: proc(f: ^File_Impl) -> (n: i64, err: Error) { _file_size :: proc(f: ^File_Impl) -> (n: i64, err: Error) {
length: win32.LARGE_INTEGER length: win32.LARGE_INTEGER
handle := _handle(&f.file)
if f.kind == .Pipe { if f.kind == .Pipe {
bytesAvail: u32
if win32.PeekNamedPipe(handle, nil, 0, nil, &bytesAvail, nil) {
return i64(bytesAvail), nil
} else {
return 0, .No_Size return 0, .No_Size
} }
handle := _handle(&f.file) }
if !win32.GetFileSizeEx(handle, &length) { if !win32.GetFileSizeEx(handle, &length) {
err = _get_platform_error() err = _get_platform_error()
} }