Skip to content

Commit c72cb9e

Browse files
ChrisDentondjc
authored andcommitted
Windows: Try using symlinks if they're allowed
1 parent 3f0213f commit c72cb9e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/utils/raw.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ pub fn append_file(dest: &Path, line: &str) -> io::Result<()> {
134134
pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> {
135135
#[cfg(windows)]
136136
fn symlink_dir_inner(src: &Path, dest: &Path) -> io::Result<()> {
137-
// std's symlink uses Windows's symlink function, which requires
138-
// admin. We can create directory junctions the hard way without
139-
// though.
140-
symlink_junction_inner(src, dest)
137+
// On Windows creating symlinks isn't allowed by default so if it fails
138+
// we fallback to creating a directory junction.
139+
std::os::windows::fs::symlink_dir(src, dest).or_else(|_| symlink_junction_inner(src, dest))
141140
}
142141
#[cfg(not(windows))]
143142
fn symlink_dir_inner(src: &Path, dest: &Path) -> io::Result<()> {

0 commit comments

Comments
 (0)