MCPcopy Index your code
hub / github.com/AI45Lab/Code / normalize_absolute_path_lexical

Function normalize_absolute_path_lexical

core/src/workspace/local.rs:658–674  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

656}
657
658fn 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)]
677mod tests {

Callers 1

normalize_absolute_pathFunction · 0.85

Calls 1

popMethod · 0.80

Tested by

no test coverage detected