fix: improve get_file_name_from_path to use std Path

This commit is contained in:
Mohammad Kanaan 2026-07-27 13:08:12 +03:00
parent 2001434ab5
commit c7002aef34

View file

@ -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"),
}
}