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
22 changes: 16 additions & 6 deletions src/uucore/src/lib/features/buf_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,27 @@
//! does not handle copying special files (e.g pipes, character/block devices).

#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod linux;
use std::os::fd::AsFd;
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use linux::*;
pub fn copy_stream(
src: &mut (impl std::io::Read + AsFd),
dest: &mut impl AsFd,
) -> std::io::Result<()> {
// try to splice() system call for throughput
if crate::pipes::splice_unbounded_auto(src, dest)?.is_err() {
// fall back on writing "without buffering", or order of output would be wrong
// unrelated for cp /dev/stdin since cp does not have multiple input? <https://github.com/uutils/coreutils/issues/5186>
// RawWriter also removes io::copy's specialization slower than our splice
std::io::copy(src, &mut crate::io::RawWriter(dest))?;
}
Ok(())
}

#[cfg(not(any(target_os = "linux", target_os = "android")))]
pub mod other;
#[cfg(not(any(target_os = "linux", target_os = "android")))]
pub use other::copy_stream;
pub use std::io::copy as copy_stream;

#[cfg(test)]
#[cfg(any(target_os = "linux", target_os = "android"))] // copy_stream is a thin wrapper for io::copy. nothing to test...
#[cfg(any(target_os = "linux", target_os = "android"))] // copy_stream is io::copy on other platforms. nothing to test.
mod tests {
use super::*;
use std::fs::File;
Expand Down
33 changes: 0 additions & 33 deletions src/uucore/src/lib/features/buf_copy/linux.rs

This file was deleted.

27 changes: 0 additions & 27 deletions src/uucore/src/lib/features/buf_copy/other.rs

This file was deleted.

Loading