Trying CI.

This commit is contained in:
Andrew Gallant
2016-09-05 20:08:46 -04:00
parent 02ac331529
commit 1a3e7c0bb2
6 changed files with 276 additions and 107 deletions

View File

@@ -5,9 +5,6 @@ redirected to a file? etc... We use this information to tweak various default
configuration parameters such as colors and match formatting.
*/
use std::fs::{File, Metadata};
use std::io;
use libc;
#[cfg(unix)]
@@ -43,97 +40,3 @@ pub fn stdout_is_atty() -> bool {
kernel32::GetConsoleMode(handle, &mut out) != 0
}
}
// Probably everything below isn't actually needed. ---AG
#[cfg(unix)]
pub fn metadata(fd: libc::c_int) -> Result<Metadata, io::Error> {
use std::os::unix::io::{FromRawFd, IntoRawFd};
let f = unsafe { File::from_raw_fd(fd) };
let md = f.metadata();
// Be careful to transfer ownership back to a simple descriptor. Dropping
// the File itself would close the descriptor, which would be quite bad!
drop(f.into_raw_fd());
md
}
#[cfg(unix)]
pub fn stdin_is_file() -> bool {
metadata(libc::STDIN_FILENO)
.map(|md| md.file_type().is_file())
.unwrap_or(false)
}
#[cfg(unix)]
pub fn stdout_is_file() -> bool {
metadata(libc::STDOUT_FILENO)
.map(|md| md.file_type().is_file())
.unwrap_or(false)
}
#[cfg(unix)]
pub fn stdin_is_char_device() -> bool {
use std::os::unix::fs::FileTypeExt;
metadata(libc::STDIN_FILENO)
.map(|md| md.file_type().is_char_device())
.unwrap_or(false)
}
#[cfg(unix)]
pub fn stdout_is_char_device() -> bool {
use std::os::unix::fs::FileTypeExt;
metadata(libc::STDOUT_FILENO)
.map(|md| md.file_type().is_char_device())
.unwrap_or(false)
}
#[cfg(unix)]
pub fn stdin_is_fifo() -> bool {
use std::os::unix::fs::FileTypeExt;
metadata(libc::STDIN_FILENO)
.map(|md| md.file_type().is_fifo())
.unwrap_or(false)
}
#[cfg(unix)]
pub fn stdout_is_fifo() -> bool {
use std::os::unix::fs::FileTypeExt;
metadata(libc::STDOUT_FILENO)
.map(|md| md.file_type().is_fifo())
.unwrap_or(false)
}
#[cfg(windows)]
pub fn stdin_is_file() -> bool {
false
}
#[cfg(windows)]
pub fn stdout_is_file() -> bool {
false
}
#[cfg(windows)]
pub fn stdin_is_char_device() -> bool {
false
}
#[cfg(windows)]
pub fn stdout_is_char_device() -> bool {
false
}
#[cfg(windows)]
pub fn stdin_is_fifo() -> bool {
false
}
#[cfg(windows)]
pub fn stdout_is_fifo() -> bool {
false
}