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::{ use std::{
fs::File, fs::File,
io::{BufRead, BufReader}, io::{BufRead, BufReader},
path::Path,
}; };
use anyhow::Context; use anyhow::Context;
@ -23,9 +24,9 @@ pub fn read_lines(
} }
fn get_file_name_from_path(file_path: &str) -> String { fn get_file_name_from_path(file_path: &str) -> String {
match file_path.rsplit('/').next() { match Path::new(file_path).file_name() {
Some(name) => name.into(), Some(name) => name.to_string_lossy().to_string(),
None => file_path.into(), None => String::from("unknown"),
} }
} }