MCPcopy Create free account
hub / github.com/dallay/agentsync / remove_existing_path

Function remove_existing_path

src/linker.rs:1684–1699  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

1682}
1683
1684fn remove_existing_path(path: &Path) -> std::io::Result<()> {
1685 let metadata = match fs::symlink_metadata(path) {
1686 Ok(metadata) => metadata,
1687 Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
1688 Err(err) => return Err(err),
1689 };
1690
1691 let file_type = metadata.file_type();
1692 if file_type.is_symlink() {
1693 remove_symlink(path)
1694 } else if metadata.is_dir() {
1695 fs::remove_dir_all(path)
1696 } else {
1697 fs::remove_file(path)
1698 }
1699}
1700
1701/// Remove a symlink, handling both file and directory symlinks cross-platform.
1702/// On Windows, directory symlinks require `fs::remove_dir()` instead of `fs::remove_file()`.

Callers 1

create_symlinkMethod · 0.85

Calls 1

remove_symlinkFunction · 0.85

Tested by

no test coverage detected