From 1389b75d0af36d627170ea121f5101d84304fcd2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Apr 2024 23:05:23 -0700 Subject: [PATCH] try win --- src/input.rs | 7 +++++-- src/subprocess.rs | 10 +--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/input.rs b/src/input.rs index 20cfc5e4..22b52e72 100644 --- a/src/input.rs +++ b/src/input.rs @@ -21,6 +21,11 @@ use { }, }; +#[cfg(target_family = "unix")] +use std::os::unix::ffi::OsStringExt; +#[cfg(target_family = "windows")] +use std::os::windows::ffi::OsStringExt; + #[derive(Debug)] pub enum RowIn { Entire(PathBuf), @@ -131,12 +136,10 @@ async fn stream_patch(patches: &Path) -> impl Stream> fn u8_pathbuf(v8: Vec) -> PathBuf { #[cfg(target_family = "unix")] { - use std::os::unix::ffi::OsStringExt; PathBuf::from(OsString::from_vec(v8)) } #[cfg(target_family = "windows")] { - use std::os::windows::ffi::OsStringExt; let mut buf = Vec::new(); for chunk in v8.chunks_exact(2) { let c: [u8; 2] = chunk.try_into().expect("exact chunks"); diff --git a/src/subprocess.rs b/src/subprocess.rs index 34ceb37a..b1fc4353 100644 --- a/src/subprocess.rs +++ b/src/subprocess.rs @@ -40,15 +40,7 @@ where Err(e) } Some(Ok(print)) => { - #[cfg(target_family = "unix")] - let bytes = { - use std::os::unix::ffi::OsStrExt; - print.as_bytes() - }; - #[cfg(target_family = "windows")] - let tmp = print.to_string_lossy(); - #[cfg(target_family = "windows")] - let bytes = tmp.as_bytes(); + let bytes = print.as_encoded_bytes(); s.1 .write_all(bytes) .await