Escape invalid unicode encoded names

This commit is contained in:
Peltoche 2018-12-05 21:13:36 +01:00 committed by Pierre Peltier
parent 526f020695
commit 268f7bf79f
2 changed files with 3 additions and 6 deletions

View file

@ -16,8 +16,7 @@ impl Name {
let mut name = path
.file_name()
.expect("failed to retrieve file name")
.to_str()
.expect("failed to encode file name")
.to_string_lossy()
.to_string();
if file_type == FileType::Directory {

View file

@ -14,15 +14,13 @@ impl<'a> From<&'a Metadata> for Owner {
let user = get_user_by_uid(meta.uid())
.expect("failed to get user name")
.name()
.to_str()
.expect("failed to convert user name to str")
.to_string_lossy()
.to_string();
let group = get_group_by_gid(meta.gid())
.expect("failed to get the group name")
.name()
.to_str()
.expect("failed to convert group name to str")
.to_string_lossy()
.to_string();
Owner { user, group }