std: Move platform specific stdio code into sys
This commit is contained in:
parent
fea1bd4cdf
commit
d311079a6f
3 changed files with 6 additions and 5 deletions
|
|
@ -125,13 +125,10 @@ impl<R: io::Read> io::Read for Maybe<R> {
|
|||
}
|
||||
|
||||
fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
|
||||
#[cfg(windows)]
|
||||
const ERR: i32 = ::sys::c::ERROR_INVALID_HANDLE as i32;
|
||||
#[cfg(not(windows))]
|
||||
const ERR: i32 = ::libc::EBADF as i32;
|
||||
use sys::stdio::EBADF_ERR;
|
||||
|
||||
match r {
|
||||
Err(ref e) if e.raw_os_error() == Some(ERR) => Ok(default),
|
||||
Err(ref e) if e.raw_os_error() == Some(EBADF_ERR) => Ok(default),
|
||||
r => r
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,3 +65,5 @@ impl io::Write for Stderr {
|
|||
}
|
||||
fn flush(&mut self) -> io::Result<()> { Ok(()) }
|
||||
}
|
||||
|
||||
pub const EBADF_ERR: i32 = ::libc::EBADF as i32;
|
||||
|
|
|
|||
|
|
@ -205,3 +205,5 @@ impl Output {
|
|||
fn invalid_encoding() -> io::Error {
|
||||
io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode")
|
||||
}
|
||||
|
||||
pub const EBADF_ERR: i32 = ::sys::c::ERROR_INVALID_HANDLE as i32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue