mirror of
https://github.com/openharmony/third_party_rust_atty.git
synced 2026-07-01 09:25:06 -04:00
add support of the unikernel RustyHermit
- use the crate hermit-abi as interface to the kernel
This commit is contained in:
@@ -17,6 +17,9 @@ travis-ci = { repository = "softprops/atty" }
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = { version = "0.2", default-features = false }
|
||||
|
||||
[target.'cfg(target_os = "hermit")'.dependencies]
|
||||
hermit-abi = "0.1.6"
|
||||
|
||||
[target.'cfg(windows)'.dependencies.winapi]
|
||||
version = "0.3"
|
||||
features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"]
|
||||
|
||||
+13
@@ -48,6 +48,19 @@ pub fn is(stream: Stream) -> bool {
|
||||
unsafe { libc::isatty(fd) != 0 }
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(target_os = "hermit")]
|
||||
pub fn is(stream: Stream) -> bool {
|
||||
extern crate hermit_abi;
|
||||
|
||||
let fd = match stream {
|
||||
Stream::Stdout => hermit_abi::STDOUT_FILENO,
|
||||
Stream::Stderr => hermit_abi::STDERR_FILENO,
|
||||
Stream::Stdin => hermit_abi::STDIN_FILENO,
|
||||
};
|
||||
hermit_abi::isatty(fd)
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(windows)]
|
||||
pub fn is(stream: Stream) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user