MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / expand_dst

Function expand_dst

atomic-agent/src/integrations/install.rs:290–306  ·  view source on GitHub ↗

Expand a leading `~` in a destination path.

(dst: &str)

Source from the content-addressed store, hash-verified

288
289/// Expand a leading `~` in a destination path.
290fn expand_dst(dst: &str) -> AgentResult<PathBuf> {
291 if dst == "~" {
292 return dirs::home_dir().ok_or_else(|| AgentError::Integration {
293 agent: "<any>".to_string(),
294 reason: "cannot resolve home directory".to_string(),
295 });
296 }
297 if let Some(rest) = dst.strip_prefix("~/") {
298 return dirs::home_dir()
299 .map(|h| h.join(rest))
300 .ok_or_else(|| AgentError::Integration {
301 agent: "<any>".to_string(),
302 reason: "cannot resolve home directory".to_string(),
303 });
304 }
305 Ok(PathBuf::from(dst))
306}
307
308/// Reject `src` paths that would escape the package directory.
309fn reject_parent_traversal(agent: &str, src: &str) -> AgentResult<()> {

Callers 1

install_from_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected