Skip to content

Commit

Permalink
Merge pull request #1 from sunfishcode/sunfishcode/update
Browse files Browse the repository at this point in the history
Update to windows-sys 0.59.
  • Loading branch information
sunfishcode authored Sep 12, 2024
2 parents ffa36e6 + 21a8510 commit 93d5e33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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()) });
}
}

0 comments on commit 93d5e33

Please sign in to comment.