summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/file.rs8
-rw-r--r--src/devices/file/directory_listing.rs6
2 files changed, 14 insertions, 0 deletions
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(());
};
diff --git a/src/devices/file/directory_listing.rs b/src/devices/file/directory_listing.rs
index 6d669e5..341f353 100644
--- a/src/devices/file/directory_listing.rs
+++ b/src/devices/file/directory_listing.rs
@@ -21,6 +21,9 @@ impl DirectoryListing {
};
let entry = continue_on_err!(entry_result);
let path = continue_on_err!(remove_base(&entry.path(), &base));
+ #[cfg(target_family = "unix")]
+ let byte_path = path.as_os_str().as_bytes();
+ #[cfg(target_family = "windows")]
let byte_path = path.as_os_str().as_encoded_bytes();
if byte_path.len() > 255 {
continue;
@@ -107,6 +110,9 @@ pub fn remove_base(absolute_path: &Path, base_path: &Path) -> Result<PathBuf, ()
// Returns true if a dot character directly follows the right-most
// forward-slash character in the path.
fn filename_dot_prefixed(path: &Path) -> bool {
+ #[cfg(target_family = "unix")]
+ let bytes = path.as_os_str().as_bytes();
+ #[cfg(target_family = "windows")]
let bytes = path.as_os_str().as_encoded_bytes();
// Find position of final forward-slash byte.
let mut final_slash = None;