Skip to content

Commit

Permalink
fix(windows): fix build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
brglng committed Oct 9, 2024
1 parent 586aebe commit dc15fd7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/path_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::io::Write;
use std::mem::align_of;
use std::mem::size_of;
use std::num::Wrapping;
use std::os::unix::ffi::OsStrExt;
use std::path::Path;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
Expand Down Expand Up @@ -163,7 +162,7 @@ impl TempfilePathQueue {
// safe if and only if there is only one push thread
pub fn push(&mut self, path: &Path) -> Result<()> {
let writer = unsafe { &mut *self.writer.get() };
writer.write_all(path.as_os_str().as_bytes())?;
writer.write_all(path.as_os_str().as_encoded_bytes())?;
writer.write_all(b"\0")?;
writer.flush()?;
self.push_count.fetch_add(1, Ordering::Release);
Expand All @@ -183,7 +182,7 @@ impl TempfilePathQueue {
let delim = buffer.pop();
assert_eq!(delim, Some(b'\0'));
self.pop_count.fetch_add(1, Ordering::Release);
let path = PathBuf::from(OsStr::from_bytes(&buffer));
let path = PathBuf::from(unsafe { OsStr::from_encoded_bytes_unchecked(&buffer) });
Ok(Some(path))
}

Expand Down

0 comments on commit dc15fd7

Please # to comment.