MCPcopy Create free account
hub / github.com/AI45Lab/Code / safe_canonicalize

Function safe_canonicalize

core/src/agent_api.rs:78–83  ·  view source on GitHub ↗

Canonicalize a path, stripping the Windows `\\?\` UNC prefix to avoid polluting workspace strings throughout the system (prompts, session data, etc.).

(path: &Path)

Source from the content-addressed store, hash-verified

76/// Canonicalize a path, stripping the Windows `\\?\` UNC prefix to avoid
77/// polluting workspace strings throughout the system (prompts, session data, etc.).
78fn safe_canonicalize(path: &Path) -> PathBuf {
79 match std::fs::canonicalize(path) {
80 Ok(p) => strip_unc_prefix(p),
81 Err(_) => path.to_path_buf(),
82 }
83}
84
85/// Strip the Windows extended-length path prefix (`\\?\`) that `canonicalize()` adds.
86/// On non-Windows this is a no-op.

Callers 1

build_agent_sessionFunction · 0.85

Calls 1

strip_unc_prefixFunction · 0.85

Tested by

no test coverage detected