summaryrefslogtreecommitdiff
path: root/src/devices/file/directory_listing.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/file/directory_listing.rs')
-rw-r--r--src/devices/file/directory_listing.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/devices/file/directory_listing.rs b/src/devices/file/directory_listing.rs
index 0709fc3..6d669e5 100644
--- a/src/devices/file/directory_listing.rs
+++ b/src/devices/file/directory_listing.rs
@@ -1,10 +1,5 @@
use super::*;
-use std::ffi::OsString;
-use std::os::unix::ffi::{OsStrExt, OsStringExt};
-use std::path::{Component, Path, PathBuf};
-
-
pub struct DirectoryListing {
children: Vec<DirectoryChild>,
length: u32,
@@ -26,7 +21,7 @@ impl DirectoryListing {
};
let entry = continue_on_err!(entry_result);
let path = continue_on_err!(remove_base(&entry.path(), &base));
- let byte_path = path.as_os_str().as_bytes();
+ let byte_path = path.as_os_str().as_encoded_bytes();
if byte_path.len() > 255 {
continue;
};
@@ -87,8 +82,7 @@ impl DirectoryListing {
pub fn child_path(&self) -> Option<PathBuf> {
self.selected.and_then(|s| self.get(s).and_then(|i| {
- let os_string: OsString = OsStringExt::from_vec(i.byte_path.clone());
- Some(os_string.into())
+ Some(bytes_to_path(&i.byte_path))
}))
}
}
@@ -113,7 +107,7 @@ 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 {
- let bytes = path.as_os_str().as_bytes();
+ let bytes = path.as_os_str().as_encoded_bytes();
// Find position of final forward-slash byte.
let mut final_slash = None;
for (i, byte) in bytes.iter().enumerate() {