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

Method remove_path

atomic-core/src/output/memory.rs:596–627  ·  view source on GitHub ↗
(&self, path: &str, recursive: bool)

Source from the content-addressed store, hash-verified

594 }
595
596 fn remove_path(&self, path: &str, recursive: bool) -> Result<(), Self::Error> {
597 let mut files = self.files.borrow_mut();
598
599 // Check if path exists
600 if !files.contains_key(path) {
601 return Err(MemoryError::NotFound {
602 path: path.to_string(),
603 });
604 }
605
606 // Check if it's a directory with contents
607 let is_dir = files.get(path).map(|f| f.metadata.is_dir).unwrap_or(false);
608 if is_dir && !recursive {
609 // Check for children
610 let prefix = format!("{}/", path);
611 if files.keys().any(|p| p.starts_with(&prefix)) {
612 return Err(MemoryError::DirectoryNotEmpty {
613 path: path.to_string(),
614 });
615 }
616 }
617
618 if recursive {
619 // Remove all paths that start with this path
620 let prefix = format!("{}/", path);
621 files.retain(|p, _| !p.starts_with(&prefix) && p != path);
622 } else {
623 files.remove(path);
624 }
625
626 Ok(())
627 }
628
629 fn rename(&self, from: &str, to: &str) -> Result<(), Self::Error> {
630 let mut files = self.files.borrow_mut();

Calls 3

contains_keyMethod · 0.80
getMethod · 0.65
removeMethod · 0.65