20
20
#[ cfg( unix) ]
21
21
extern crate libc;
22
22
#[ cfg( windows) ]
23
- extern crate winapi ;
23
+ extern crate windows_sys ;
24
24
25
25
#[ cfg( windows) ]
26
- use winapi:: shared:: minwindef:: DWORD ;
27
- #[ cfg( windows) ]
28
- use winapi:: shared:: ntdef:: WCHAR ;
26
+ use windows_sys:: Win32 :: System :: Console :: STD_HANDLE ;
29
27
30
28
/// possible stream sources
31
29
#[ derive( Clone , Copy , Debug ) ]
@@ -64,7 +62,7 @@ pub fn is(stream: Stream) -> bool {
64
62
/// returns true if this is a tty
65
63
#[ cfg( windows) ]
66
64
pub fn is ( stream : Stream ) -> bool {
67
- use winapi :: um :: winbase :: {
65
+ use windows_sys :: Win32 :: System :: Console :: {
68
66
STD_ERROR_HANDLE as STD_ERROR , STD_INPUT_HANDLE as STD_INPUT ,
69
67
STD_OUTPUT_HANDLE as STD_OUTPUT ,
70
68
} ;
@@ -100,8 +98,8 @@ pub fn isnt(stream: Stream) -> bool {
100
98
101
99
/// Returns true if any of the given fds are on a console.
102
100
#[ cfg( windows) ]
103
- unsafe fn console_on_any ( fds : & [ DWORD ] ) -> bool {
104
- use winapi :: um :: { consoleapi :: GetConsoleMode , processenv :: GetStdHandle } ;
101
+ unsafe fn console_on_any ( fds : & [ STD_HANDLE ] ) -> bool {
102
+ use windows_sys :: Win32 :: System :: Console :: { GetConsoleMode , GetStdHandle } ;
105
103
106
104
for & fd in fds {
107
105
let mut out = 0 ;
@@ -115,20 +113,18 @@ unsafe fn console_on_any(fds: &[DWORD]) -> bool {
115
113
116
114
/// Returns true if there is an MSYS tty on the given handle.
117
115
#[ cfg( windows) ]
118
- unsafe fn msys_tty_on ( fd : DWORD ) -> bool {
116
+ unsafe fn msys_tty_on ( fd : STD_HANDLE ) -> bool {
119
117
use std:: { mem, slice} ;
120
118
121
- use winapi:: {
122
- ctypes:: c_void,
123
- shared:: minwindef:: MAX_PATH ,
124
- um:: {
125
- fileapi:: FILE_NAME_INFO , minwinbase:: FileNameInfo , processenv:: GetStdHandle ,
126
- winbase:: GetFileInformationByHandleEx ,
127
- } ,
119
+ use std:: ffi:: c_void;
120
+ use windows_sys:: Win32 :: {
121
+ Foundation :: MAX_PATH ,
122
+ Storage :: FileSystem :: { FileNameInfo , GetFileInformationByHandleEx , FILE_NAME_INFO } ,
123
+ System :: Console :: GetStdHandle ,
128
124
} ;
129
125
130
126
let size = mem:: size_of :: < FILE_NAME_INFO > ( ) ;
131
- let mut name_info_bytes = vec ! [ 0u8 ; size + MAX_PATH * mem:: size_of:: <WCHAR >( ) ] ;
127
+ let mut name_info_bytes = vec ! [ 0u8 ; size + ( MAX_PATH as usize ) * mem:: size_of:: <u16 >( ) ] ;
132
128
let res = GetFileInformationByHandleEx (
133
129
GetStdHandle ( fd) ,
134
130
FileNameInfo ,
0 commit comments