File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,25 @@ fn isatty(stream: Stream) -> bool {
345
345
unsafe { libc:: isatty ( fd) != 0 }
346
346
}
347
347
348
- #[ cfg( not ( unix ) ) ]
348
+ #[ cfg( windows ) ]
349
349
fn isatty ( stream : Stream ) -> bool {
350
- false
350
+ use winapi:: um:: consoleapi:: GetConsoleMode ;
351
+ use winapi:: um:: handleapi:: INVALID_HANDLE_VALUE ;
352
+ use winapi:: um:: processenv:: GetStdHandle ;
353
+ use winapi:: um:: winbase:: { STD_OUTPUT_HANDLE , STD_ERROR_HANDLE } ;
354
+
355
+ let handle = match stream {
356
+ Stream :: Stdout => STD_OUTPUT_HANDLE ,
357
+ Stream :: Stderr => STD_ERROR_HANDLE ,
358
+ } ;
359
+
360
+ unsafe {
361
+ let handle = GetStdHandle ( handle) ;
362
+ if handle == INVALID_HANDLE_VALUE {
363
+ return false ;
364
+ }
365
+
366
+ let mut mode: u32 = 0 ;
367
+ GetConsoleMode ( handle, & mut mode) != 0
368
+ }
351
369
}
You can’t perform that action at this time.
0 commit comments