From b82ffe72b3f72b8fc5e42464319bab69973c097f Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sun, 4 Aug 2024 13:09:04 +1200 Subject: Fix compilation on Linux Some Windows-only library functions were added in during a previous commit while I was developing on Windows. --- src/devices/file.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/devices/file.rs') diff --git a/src/devices/file.rs b/src/devices/file.rs index fc1b56c..2a00a59 100644 --- a/src/devices/file.rs +++ b/src/devices/file.rs @@ -12,6 +12,8 @@ pub use directory_listing::*; pub use entry::*; use operations::*; +#[cfg(target_family = "unix")] +use std::os::unix::ffi::OsStrExt; use std::fs::{OpenOptions, metadata}; use std::path::{Component, Path, PathBuf}; @@ -129,6 +131,9 @@ impl FileDevice { let file_entry = Entry::File(BufferedFile::new(file)); self.entry = Some((file_entry, path.to_owned())); let relative = remove_base(&path, &self.base_path).unwrap(); + #[cfg(target_family = "unix")] + self.name_buffer.populate(relative.as_os_str().as_bytes()); + #[cfg(target_family = "windows")] self.name_buffer.populate(relative.as_os_str().as_encoded_bytes()); return Ok(()); }; @@ -137,6 +142,9 @@ impl FileDevice { let dir_entry = Entry::Directory(listing); self.entry = Some((dir_entry, path.to_owned())); let relative = remove_base(&path, &self.base_path).unwrap(); + #[cfg(target_family = "unix")] + self.name_buffer.populate(relative.as_os_str().as_bytes()); + #[cfg(target_family = "windows")] self.name_buffer.populate(relative.as_os_str().as_encoded_bytes()); return Ok(()); }; -- cgit v1.2.3-70-g09d2