ln: Make sure we can symlink directories on Windows.

This commit is contained in:
Zephiris
2016-11-05 00:22:55 -07:00
parent 7bb5891810
commit ca8f5516e9
+11 -3
View File
@@ -15,8 +15,8 @@ extern crate uucore;
use std::fs;
use std::io::{BufRead, BufReader, Result, stdin, Write};
#[cfg(unix)] use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)] use std::os::windows::fs::symlink_file;
#[cfg(unix)] use std::os::unix::fs::symlink;
#[cfg(windows)] use std::os::windows::fs::{symlink_file,symlink_dir};
use std::path::{Path, PathBuf};
static NAME: &'static str = "ln";
@@ -292,8 +292,16 @@ fn existing_backup_path(path: &PathBuf, suffix: &str) -> PathBuf {
simple_backup_path(path, suffix)
}
#[cfg(windows)]
pub fn symlink<P: AsRef<Path>>(src: P, dst: P) -> Result<()> {
symlink_file(src, dst)
if src.as_ref().is_dir()
{
symlink_dir(src,dst)
}
else
{
symlink_file(src,dst)
}
}
pub fn is_symlink<P: AsRef<Path>>(path: P) -> bool {