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

Method remove_path

atomic-core/src/output/filesystem/mod.rs:247–266  ·  view source on GitHub ↗

Remove a file or directory. If `recursive` is true, removes directories and their contents.

(&self, path: &str, recursive: bool)

Source from the content-addressed store, hash-verified

245 ///
246 /// If `recursive` is true, removes directories and their contents.
247 fn remove_path(&self, path: &str, recursive: bool) -> Result<(), Self::Error> {
248 let abs_path = self.resolve_path(path)?;
249
250 if !abs_path.exists() {
251 return Err(io::Error::new(
252 io::ErrorKind::NotFound,
253 format!("Path not found: {}", path),
254 ));
255 }
256
257 if abs_path.is_dir() {
258 if recursive {
259 fs::remove_dir_all(&abs_path)
260 } else {
261 fs::remove_dir(&abs_path)
262 }
263 } else {
264 fs::remove_file(&abs_path)
265 }
266 }
267
268 /// Rename a file or directory.
269 fn rename(&self, from: &str, to: &str) -> Result<(), Self::Error> {

Callers 6

test_remove_fileFunction · 0.45
test_remove_recursiveFunction · 0.45
test_remove_not_foundFunction · 0.45
test_full_workflowFunction · 0.45

Calls 3

is_dirMethod · 0.80
resolve_pathMethod · 0.45
existsMethod · 0.45

Tested by 6

test_remove_fileFunction · 0.36
test_remove_recursiveFunction · 0.36
test_remove_not_foundFunction · 0.36
test_full_workflowFunction · 0.36