about summary refs log tree commit diff
path: root/library/std/src/sys/windows/io.rs
AgeCommit message (Collapse)AuthorLines
2023-02-23Fix `is_terminal`'s handling of long paths on Windows.Dan Gohman-11/+21
As reported in sunfishcode/is-terminal#18, there are situations where `GetFileInformationByHandleEx` can write a file name length that is longer than the provided buffer. To avoid deferencing memory past the end of the buffer, use a bounds-checked function to form a slice to the buffer and handle the out-of-bounds case. This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal` implementation.
2022-10-21Reduce false positives in msys2 detectionChris Denton-2/+9
This checks that: * the handle is a pipe * the pipe's file name starts with "msys-" or "cygwin-" rather than looking in the full path.
2022-10-15Use Align8 to avoid misalignment if the allocator or Vec doesn't align ↵Josh Triplett-7/+7
allocations
2022-10-15Rewrite FILE_NAME_INFO handling to avoid enlarging slice referenceJosh Triplett-4/+4
Rather than referencing a slice's pointer and then creating a new slice with a longer length, offset from the base structure pointer instead. This makes some choices of Rust semantics happier.
2022-10-15Make is_terminal fail fast if a process has no console at allJosh Triplett-1/+9
If a process has no console, it'll have NULL in place of a console handle, so return early with `false` in that case without making any OS calls.
2022-10-15Add `IsTerminal` trait to determine if a descriptor or handle is a terminalJosh Triplett-0/+59
The UNIX and WASI implementations use `isatty`. The Windows implementation uses the same logic the `atty` crate uses, including the hack needed to detect msys terminals. Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and their locked counterparts on all platforms. On UNIX and WASI, implement it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for `BorrowedHandle`/`OwnedHandle`. Based on https://github.com/rust-lang/rust/pull/91121 Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
2020-07-27mv std libs to library/mark-0/+80