Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/od/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ byteorder = { workspace = true }
clap = { workspace = true }
half = { workspace = true }
rustix = { workspace = true, features = ["stdio"] }
uucore = { workspace = true, features = ["parser-size"] }
uucore = { workspace = true, features = ["fs", "parser-size"] }
fluent = { workspace = true }
libc.workspace = true

Expand Down
10 changes: 1 addition & 9 deletions src/uu/od/src/multifile_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,7 @@ impl MultifileReader<'_> {
// limit.
#[cfg(any(unix, target_os = "wasi"))]
{
use std::os::fd::AsFd;
// todo: definition is generic enough to move to uucore::io::RawReader if useful
struct RawReader<T: AsFd>(pub T);
impl<T: AsFd> io::Read for RawReader<T> {
fn read(&mut self, b: &mut [u8]) -> io::Result<usize> {
rustix::io::read(&self.0, b).map_err(Into::into)
}
}
let stdin = RawReader(rustix::stdio::stdin());
let stdin = uucore::io::RawReader(rustix::stdio::stdin());
self.curr_file = Some(Box::new(stdin));
}

Expand Down
10 changes: 10 additions & 0 deletions src/uucore/src/lib/mods/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ type NativeType = OwnedHandle;
#[cfg(not(windows))]
type NativeType = OwnedFd;

// create reader without buffering
#[cfg(any(unix, target_os = "wasi"))]
pub struct RawReader<T: AsFd>(pub T);
#[cfg(any(unix, target_os = "wasi"))]
impl<T: AsFd> io::Read for RawReader<T> {
fn read(&mut self, b: &mut [u8]) -> io::Result<usize> {
rustix::io::read(&self.0, b).map_err(Into::into)
}
}

// create writer without buffering
#[cfg(any(unix, target_os = "wasi"))]
pub struct RawWriter<T: AsFd>(pub T);
Expand Down
Loading