mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uucore/fs: make function more generic
This commit is contained in:
@@ -274,12 +274,12 @@ fn process_relative(
|
||||
) -> PathBuf {
|
||||
if let Some(base) = relative_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 {
|
||||
path
|
||||
}
|
||||
} else if let Some(to) = relative_to {
|
||||
make_path_relative_to(path.as_path(), to)
|
||||
make_path_relative_to(path, to)
|
||||
} else {
|
||||
path
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
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 to = to.as_ref();
|
||||
let common_prefix_size = path
|
||||
|
||||
Reference in New Issue
Block a user