Skip to content

Commit d311079

Browse files
committed
std: Move platform specific stdio code into sys
1 parent fea1bd4 commit d311079

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/libstd/io/stdio.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,10 @@ impl<R: io::Read> io::Read for Maybe<R> {
125125
}
126126

127127
fn handle_ebadf<T>(r: io::Result<T>, default: T) -> io::Result<T> {
128-
#[cfg(windows)]
129-
const ERR: i32 = ::sys::c::ERROR_INVALID_HANDLE as i32;
130-
#[cfg(not(windows))]
131-
const ERR: i32 = ::libc::EBADF as i32;
128+
use sys::stdio::EBADF_ERR;
132129

133130
match r {
134-
Err(ref e) if e.raw_os_error() == Some(ERR) => Ok(default),
131+
Err(ref e) if e.raw_os_error() == Some(EBADF_ERR) => Ok(default),
135132
r => r
136133
}
137134
}

src/libstd/sys/unix/stdio.rs

+2
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@ impl io::Write for Stderr {
6565
}
6666
fn flush(&mut self) -> io::Result<()> { Ok(()) }
6767
}
68+
69+
pub const EBADF_ERR: i32 = ::libc::EBADF as i32;

src/libstd/sys/windows/stdio.rs

+2
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ impl Output {
205205
fn invalid_encoding() -> io::Error {
206206
io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode")
207207
}
208+
209+
pub const EBADF_ERR: i32 = ::sys::c::ERROR_INVALID_HANDLE as i32;

0 commit comments

Comments
 (0)