From aa17c063a42fa4c201b117912970532e0bf1d060 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 16 Feb 2025 18:33:08 +0800 Subject: [PATCH] .. --- yazi-adapter/src/stdin.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/yazi-adapter/src/stdin.rs b/yazi-adapter/src/stdin.rs index a0b6583a..996b91b0 100644 --- a/yazi-adapter/src/stdin.rs +++ b/yazi-adapter/src/stdin.rs @@ -1,4 +1,4 @@ -use std::{io, ops::{Deref, DerefMut}}; +use std::{io, ops::{Deref, DerefMut}, time::Duration}; pub struct AsyncStdin { inner: std::io::StdinLock<'static>, @@ -24,7 +24,7 @@ impl AsyncStdin { me } - pub fn poll(&mut self, timeout: std::time::Duration) -> std::io::Result { + pub fn poll(&mut self, timeout: Duration) -> std::io::Result { use std::os::unix::io::AsRawFd; let mut tv = libc::timeval { @@ -66,10 +66,12 @@ impl AsyncStdin { impl AsyncStdin { pub fn new(inner: std::io::StdinLock<'static>) -> Self { Self { inner } } - pub fn poll(&mut self) -> std::io::Result { - let handle = HANDLE(self.inner.as_raw_handle() as isize); + pub fn poll(&mut self, timeout: Duration) -> std::io::Result { + use std::os::windows::io::AsRawHandle; - match unsafe { WaitForSingleObject(handle, 5000) } { + let handle = self.inner.as_raw_handle(); + let millis = timeout.as_millis(); + match unsafe { WaitForSingleObject(handle, millis) } { WAIT_TIMEOUT => Ok(false), _ => Ok(true), }