(path: &Path)
| 656 | } |
| 657 | |
| 658 | fn normalize_absolute_path_lexical(path: &Path) -> Result<PathBuf> { |
| 659 | let mut out = PathBuf::new(); |
| 660 | for component in path.components() { |
| 661 | match component { |
| 662 | Component::Prefix(prefix) => out.push(prefix.as_os_str()), |
| 663 | Component::RootDir => out.push(Path::new(std::path::MAIN_SEPARATOR_STR)), |
| 664 | Component::CurDir => {} |
| 665 | Component::Normal(part) => out.push(part), |
| 666 | Component::ParentDir => { |
| 667 | if !out.pop() { |
| 668 | bail!("Invalid absolute path"); |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | Ok(out) |
| 674 | } |
| 675 | |
| 676 | #[cfg(test)] |
| 677 | mod tests { |
no test coverage detected