mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
uucore/fs: make function more generic
This commit is contained in:
parent
b76c53c090
commit
9f2a9fa6ff
2 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue