use std::path::Path;
pub struct PathUtils;
impl PathUtils {
pub fn to_relative_string(path: &Path, current_dir: &Path) -> String {
path.strip_prefix(current_dir)
.unwrap_or(path)
.to_string_lossy()
.to_string()
}
pub fn for_display(path: &Path, current_dir: &Path) -> String {
let relative = Self::to_relative_string(path, current_dir);
if relative.starts_with('/') || relative.contains(":\\") {
path.file_name()
.and_then(|name| name.to_str())
.unwrap_or("unknown")
.to_string()
} else {
relative
}
}
}