(path: &Path)
| 1682 | } |
| 1683 | |
| 1684 | fn 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()`. |
no test coverage detected