Skip to content

Commit

Permalink
try win
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-jpq committed Apr 8, 2024
1 parent 9cf475a commit 1389b75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 1 addition & 9 deletions src/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1389b75

Please sign in to comment.