(src: impl AsRef<Path>, dst: impl AsRef<Path>)
| 601 | } |
| 602 | |
| 603 | fn ln_force(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> { |
| 604 | // Check if the symlink exists without following it |
| 605 | if dst.as_ref().symlink_metadata().is_ok() { |
| 606 | fs::remove_file(dst.as_ref())?; |
| 607 | } else if let Some(dst_parent) = dst.as_ref().parent() { |
| 608 | fs::create_dir_all(dst_parent)?; |
| 609 | } |
| 610 | fs::os::unix::fs::symlink(src.as_ref(), dst.as_ref())?; |
| 611 | Ok(()) |
| 612 | } |
| 613 | |
| 614 | #[cfg(test)] |
| 615 | mod tests; |