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

Function normalize_relative_path

core/src/workspace/mod.rs:946–963  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

944}
945
946fn normalize_relative_path(path: &Path) -> Result<PathBuf> {
947 let mut out = PathBuf::new();
948 for component in path.components() {
949 match component {
950 Component::CurDir => {}
951 Component::Normal(part) => out.push(part),
952 Component::ParentDir => {
953 if !out.pop() {
954 bail!("Workspace boundary violation: path escapes workspace");
955 }
956 }
957 Component::RootDir | Component::Prefix(_) => {
958 bail!("Absolute paths are not supported by this workspace backend");
959 }
960 }
961 }
962 Ok(out)
963}
964
965fn pathbuf_to_workspace_path(path: &Path) -> WorkspacePath {
966 let display = path.to_string_lossy().replace('\\', "/");

Callers 2

normalize_virtual_pathFunction · 0.85
normalize_local_pathFunction · 0.85

Calls 1

popMethod · 0.80

Tested by

no test coverage detected