mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
uucore: drop unused function resolve_relative_path
This function is by necessity ill-defined: Depending on the context, '..' is either the logical parent directory, sometimes the physical parent directory. This function can only work for the latter case, in which case `Path::canonicalize` is often a better approach.
This commit is contained in:
parent
5c2c38c31e
commit
d25d994125
1 changed files with 0 additions and 25 deletions
|
@ -13,7 +13,6 @@ use libc::{
|
||||||
S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH,
|
S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH,
|
||||||
S_IXUSR,
|
S_IXUSR,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -195,30 +194,6 @@ impl Hash for FileInformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// resolve a relative path
|
|
||||||
pub fn resolve_relative_path(path: &Path) -> Cow<Path> {
|
|
||||||
if path.components().all(|e| e != Component::ParentDir) {
|
|
||||||
return path.into();
|
|
||||||
}
|
|
||||||
let root = Component::RootDir.as_os_str();
|
|
||||||
let mut result = env::current_dir().unwrap_or_else(|_| PathBuf::from(root));
|
|
||||||
for comp in path.components() {
|
|
||||||
match comp {
|
|
||||||
Component::ParentDir => {
|
|
||||||
if let Ok(p) = result.read_link() {
|
|
||||||
result = p;
|
|
||||||
}
|
|
||||||
result.pop();
|
|
||||||
}
|
|
||||||
Component::CurDir => (),
|
|
||||||
Component::RootDir | Component::Normal(_) | Component::Prefix(_) => {
|
|
||||||
result.push(comp.as_os_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Controls how symbolic links should be handled when canonicalizing a path.
|
/// Controls how symbolic links should be handled when canonicalizing a path.
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
pub enum MissingHandling {
|
pub enum MissingHandling {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue