1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 04:57:45 +00:00

Make the 'cat' utility build on Redox

This commit is contained in:
Ian Douglas Scott 2018-03-14 10:21:12 -07:00
parent fa0b7ed41b
commit 1471e95b22
No known key found for this signature in database
GPG key ID: 4924E10E199B5959
4 changed files with 25 additions and 2 deletions

1
Cargo.lock generated
View file

@ -1714,6 +1714,7 @@ dependencies = [
"data-encoding 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -65,7 +65,6 @@ fuchsia = [
] ]
generic = [ generic = [
"arch", "arch",
"cat",
"hashsum", "hashsum",
"hostname", "hostname",
"join", "join",
@ -96,6 +95,7 @@ redox_generic = [
"base32", "base32",
"base64", "base64",
"basename", "basename",
"cat",
"cksum", "cksum",
"comm", "comm",
"cp", "cp",

View file

@ -9,6 +9,9 @@ time = { version = "0.1.38", optional = true }
data-encoding = { version = "^1.1", optional = true } data-encoding = { version = "^1.1", optional = true }
libc = { version = "0.2.34", optional = true } libc = { version = "0.2.34", optional = true }
[target.'cfg(target_os = "redox")'.dependencies]
termion = "1.5"
[features] [features]
fs = ["libc"] fs = ["libc"]
utf8 = [] utf8 = []

View file

@ -5,12 +5,16 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
//
#[cfg(target_os = "redox")]
extern crate termion;
#[cfg(unix)] #[cfg(unix)]
use super::libc; use super::libc;
use std::env; use std::env;
use std::fs; use std::fs;
#[cfg(target_os = "redox")]
use std::io;
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
use std::io::Result as IOResult; use std::io::Result as IOResult;
use std::path::{Component, Path, PathBuf}; use std::path::{Component, Path, PathBuf};
@ -157,6 +161,11 @@ pub fn is_stdin_interactive() -> bool {
false false
} }
#[cfg(target_os = "redox")]
pub fn is_stdin_interactive() -> bool {
termion::is_tty(&io::stdin())
}
#[cfg(unix)] #[cfg(unix)]
pub fn is_stdout_interactive() -> bool { pub fn is_stdout_interactive() -> bool {
unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 } unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 }
@ -167,6 +176,11 @@ pub fn is_stdout_interactive() -> bool {
false false
} }
#[cfg(target_os = "redox")]
pub fn is_stdout_interactive() -> bool {
termion::is_tty(&io::stdout())
}
#[cfg(unix)] #[cfg(unix)]
pub fn is_stderr_interactive() -> bool { pub fn is_stderr_interactive() -> bool {
unsafe { libc::isatty(libc::STDERR_FILENO) == 1 } unsafe { libc::isatty(libc::STDERR_FILENO) == 1 }
@ -176,3 +190,8 @@ pub fn is_stderr_interactive() -> bool {
pub fn is_stderr_interactive() -> bool { pub fn is_stderr_interactive() -> bool {
false false
} }
#[cfg(target_os = "redox")]
pub fn is_stderr_interactive() -> bool {
termion::is_tty(&io::stderr())
}