diff --git a/Cargo.toml b/Cargo.toml index fb7ebf1..c37af0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ rustix = { version = "0.38.0", default-features = false, features = ["termios"] hermit-abi = "0.3.0" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = "0.59.0" features = [ "Win32_Foundation", "Win32_Storage_FileSystem", diff --git a/src/lib.rs b/src/lib.rs index 712b7d5..da19e30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,20 +104,20 @@ fn handle_is_console(handle: BorrowedHandle<'_>) -> bool { let handle = handle.as_raw_handle(); - unsafe { - // A null handle means the process has no console. - if handle.is_null() { - return false; - } + // A null handle means the process has no console. + if handle.is_null() { + return false; + } + unsafe { let mut out = 0; - if GetConsoleMode(handle as HANDLE, &mut out) != 0 { + if GetConsoleMode(handle, &mut out) != 0 { // False positives aren't possible. If we got a console then we definitely have a console. return true; } // Otherwise, we fall back to an msys hack to see if we can detect the presence of a pty. - msys_tty_on(handle as HANDLE) + msys_tty_on(handle) } } @@ -365,6 +365,6 @@ mod tests { assert!(file_path.to_string_lossy().len() > MAX_PATH as usize); let file = File::create(file_path).expect("Unable to create file"); - assert!(!unsafe { crate::msys_tty_on(file.as_raw_handle() as isize) }); + assert!(!unsafe { crate::msys_tty_on(file.as_raw_handle()) }); } }