1 use std::path::Path;
2
3 /// Create a symlink file on unix systems
4 #[cfg(target_family = "unix")]
symlink(src: &Path, dest: &Path) -> Result<(), std::io::Error>5 pub(crate) fn symlink(src: &Path, dest: &Path) -> Result<(), std::io::Error> {
6 std::os::unix::fs::symlink(src, dest)
7 }
8
9 /// Create a symlink file on windows systems
10 #[cfg(target_family = "windows")]
symlink(src: &Path, dest: &Path) -> Result<(), std::io::Error>11 pub(crate) fn symlink(src: &Path, dest: &Path) -> Result<(), std::io::Error> {
12 if src.is_dir() {
13 std::os::windows::fs::symlink_dir(src, dest)
14 } else {
15 std::os::windows::fs::symlink_file(src, dest)
16 }
17 }
18
19 /// Create a symlink file on unix systems
20 #[cfg(target_family = "unix")]
remove_symlink(path: &Path) -> Result<(), std::io::Error>21 pub(crate) fn remove_symlink(path: &Path) -> Result<(), std::io::Error> {
22 std::fs::remove_file(path)
23 }
24
25 /// Create a symlink file on windows systems
26 #[cfg(target_family = "windows")]
remove_symlink(path: &Path) -> Result<(), std::io::Error>27 pub(crate) fn remove_symlink(path: &Path) -> Result<(), std::io::Error> {
28 if path.is_dir() {
29 std::fs::remove_dir(path)
30 } else {
31 std::fs::remove_file(path)
32 }
33 }
34