diff options
Diffstat (limited to 'core/os/os2/pipe_windows.odin')
| -rw-r--r-- | core/os/os2/pipe_windows.odin | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/os/os2/pipe_windows.odin b/core/os/os2/pipe_windows.odin index ee93fb683..d6dc47c9c 100644 --- a/core/os/os2/pipe_windows.odin +++ b/core/os/os2/pipe_windows.odin @@ -15,3 +15,15 @@ _pipe :: proc() -> (r, w: ^File, err: Error) { return new_file(uintptr(p[0]), ""), new_file(uintptr(p[1]), ""), nil } +@(require_results) +_pipe_has_data :: proc(r: ^File) -> (ok: bool, err: Error) { + if r == nil || r.impl == nil { + return false, nil + } + handle := win32.HANDLE((^File_Impl)(r.impl).fd) + bytes_available: u32 + if !win32.PeekNamedPipe(handle, nil, 0, nil, &bytes_available, nil) { + return false, _get_platform_error() + } + return bytes_available > 0, nil +}
\ No newline at end of file |