mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
ln: Make sure we can symlink directories on Windows.
This commit is contained in:
parent
7bb5891810
commit
ca8f5516e9
1 changed files with 11 additions and 3 deletions
14
src/ln/ln.rs
14
src/ln/ln.rs
|
@ -15,8 +15,8 @@ extern crate uucore;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{BufRead, BufReader, Result, stdin, Write};
|
use std::io::{BufRead, BufReader, Result, stdin, Write};
|
||||||
#[cfg(unix)] use std::os::unix::fs::symlink as symlink_file;
|
#[cfg(unix)] use std::os::unix::fs::symlink;
|
||||||
#[cfg(windows)] use std::os::windows::fs::symlink_file;
|
#[cfg(windows)] use std::os::windows::fs::{symlink_file,symlink_dir};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
static NAME: &'static str = "ln";
|
static NAME: &'static str = "ln";
|
||||||
|
@ -292,8 +292,16 @@ fn existing_backup_path(path: &PathBuf, suffix: &str) -> PathBuf {
|
||||||
simple_backup_path(path, suffix)
|
simple_backup_path(path, suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
pub fn symlink<P: AsRef<Path>>(src: P, dst: P) -> Result<()> {
|
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 {
|
pub fn is_symlink<P: AsRef<Path>>(path: P) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue