mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
[os2]: Implement pipe_has_data procedure
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user