diff options
author | root <github@bigly.dog> | 2024-04-07 23:05:23 -0700 |
---|---|---|
committer | root <github@bigly.dog> | 2024-04-07 23:10:20 -0700 |
commit | 1389b75d0af36d627170ea121f5101d84304fcd2 (patch) | |
tree | ab8598b1f221d2cecfc627fbd8e1854195f979ee | |
parent | 9cf475a2ee1e94b48503cdd47b0dc027a36cc762 (diff) |
try win
-rw-r--r-- | src/input.rs | 7 | ||||
-rw-r--r-- | src/subprocess.rs | 10 |
2 files changed, 6 insertions, 11 deletions
diff --git a/src/input.rs b/src/input.rs index 20cfc5e..22b52e7 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<Item = Result<RowIn, Die>> fn u8_pathbuf(v8: Vec<u8>) -> 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 34ceb37..b1fc435 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 |