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

Method remove_path

atomic-core/src/output/filesystem/mod.rs:269–289  ·  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

267 ///
268 /// If `recursive` is true, removes directories and their contents.
269 fn remove_path(&self, path: &str, recursive: bool) -> Result<(), Self::Error> {
270 let abs_path = self.resolve_path(path)?;
271
272 if fs::symlink_metadata(&abs_path).is_err() {
273 return Err(io::Error::new(
274 io::ErrorKind::NotFound,
275 format!("Path not found: {}", path),
276 ));
277 }
278
279 let metadata = fs::symlink_metadata(&abs_path)?;
280 if metadata.is_dir() && !metadata.file_type().is_symlink() {
281 if recursive {
282 fs::remove_dir_all(&abs_path)
283 } else {
284 fs::remove_dir(&abs_path)
285 }
286 } else {
287 fs::remove_file(&abs_path)
288 }
289 }
290
291 /// Rename a file or directory.
292 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 2

is_dirMethod · 0.80
resolve_pathMethod · 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