1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

uucore/fs: make function more generic

This commit is contained in:
Niyaz Nigmatullin 2022-07-19 00:03:35 +03:00
parent b76c53c090
commit 9f2a9fa6ff
2 changed files with 3 additions and 3 deletions

View file

@ -274,12 +274,12 @@ fn process_relative(
) -> PathBuf { ) -> PathBuf {
if let Some(base) = relative_base { if let Some(base) = relative_base {
if path.starts_with(base) { if path.starts_with(base) {
make_path_relative_to(path.as_path(), relative_to.unwrap_or(base)) make_path_relative_to(path, relative_to.unwrap_or(base))
} else { } else {
path path
} }
} else if let Some(to) = relative_to { } else if let Some(to) = relative_to {
make_path_relative_to(path.as_path(), to) make_path_relative_to(path, to)
} else { } else {
path path
} }

View file

@ -489,7 +489,7 @@ pub fn paths_refer_to_same_file<P: AsRef<Path>>(p1: P, p2: P, dereference: bool)
} }
/// Converts absolute `path` to be relative to absolute `to` path. /// Converts absolute `path` to be relative to absolute `to` path.
pub fn make_path_relative_to<P: AsRef<Path>>(path: P, to: P) -> PathBuf { pub fn make_path_relative_to<P1: AsRef<Path>, P2: AsRef<Path>>(path: P1, to: P2) -> PathBuf {
let path = path.as_ref(); let path = path.as_ref();
let to = to.as_ref(); let to = to.as_ref();
let common_prefix_size = path let common_prefix_size = path