summaryrefslogtreecommitdiffstats
path: root/src/fs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-10-11 15:12:53 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-10-11 15:12:53 -0400
commit6d4a2931a3d03c2b13ad5377b2e4446c96209df4 (patch)
tree3ced56daa93271583cd56695229d2cd965198b62 /src/fs
parentf42fc9d677561c5f76f6c0c76b64755f07aed74d (diff)
fix file not displaying if file name has incorrect unicode points
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/entry.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/fs/entry.rs b/src/fs/entry.rs
index 20c2d9f..f39082a 100644
--- a/src/fs/entry.rs
+++ b/src/fs/entry.rs
@@ -22,19 +22,13 @@ impl JoshutoDirEntry {
pub fn from(direntry: &fs::DirEntry, show_icons: bool) -> std::io::Result<Self> {
let path = direntry.path();
let metadata = JoshutoMetadata::from(&path)?;
-
- let name = match direntry.file_name().into_string() {
- Ok(s) => s,
- Err(_) => {
- return Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "Failed converting OsString to String",
- ));
- }
- };
+ let name = direntry
+ .file_name()
+ .as_os_str()
+ .to_string_lossy()
+ .to_string();
let label = name.clone();
-
let label = if show_icons {
let icon = match metadata.file_type {
FileType::Directory => DIR_NODE_EXACT_MATCHES