fix: improve get_file_name_from_path to use std Path
This commit is contained in:
parent
2001434ab5
commit
c7002aef34
1 changed files with 4 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
|
|
@ -23,9 +24,9 @@ pub fn read_lines(
|
|||
}
|
||||
|
||||
fn get_file_name_from_path(file_path: &str) -> String {
|
||||
match file_path.rsplit('/').next() {
|
||||
Some(name) => name.into(),
|
||||
None => file_path.into(),
|
||||
match Path::new(file_path).file_name() {
|
||||
Some(name) => name.to_string_lossy().to_string(),
|
||||
None => String::from("unknown"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue