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 ec5d9af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 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
13 changes: 7 additions & 6 deletions src/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use {
},
};

#[cfg(target_family = "unix")]
use std::os::unix::ffi::OsStrExt;

#[derive(Clone, Debug)]
pub struct SubprocCommand {
pub prog: PathBuf,
Expand Down Expand Up @@ -41,14 +44,12 @@ where
}
Some(Ok(print)) => {
#[cfg(target_family = "unix")]
let bytes = {
use std::os::unix::ffi::OsStrExt;
print.as_bytes()
};
let bytes = print.as_bytes();
//encode_wide
#[cfg(target_family = "windows")]
let tmp = print.to_string_lossy();
let tmp = print.into_encoded_bytes();
#[cfg(target_family = "windows")]
let bytes = tmp.as_bytes();
let bytes = &tmp;
s.1
.write_all(bytes)
.await
Expand Down

0 comments on commit ec5d9af

Please sign in to comment.