Skip to content

Commit

Permalink
Merge pull request #823 from rust-lang-nursery/db-reparse-point-fix
Browse files Browse the repository at this point in the history
Canonicalize the path and then strip off the `\\?\` prefix before cre…
  • Loading branch information
brson authored Nov 21, 2016
2 parents 1bedbb1 + 8bb1358 commit ae9d9ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rustup-utils/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
inner(s.as_ref())
}

// We're using low-level APIs to create the junction, and these are more picky about paths.
// For example, forward slashes cannot be used as a path separator, so we should try to
// canonicalize the path first.
let target = try!(fs::canonicalize(target));

try!(fs::create_dir(junction));

let path = try!(to_u16s(junction));
Expand All @@ -228,7 +233,7 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
// FIXME: this conversion is very hacky
let v = br"\??\";
let v = v.iter().map(|x| *x as u16);
for c in v.chain(target.as_os_str().encode_wide()) {
for c in v.chain(target.as_os_str().encode_wide().skip(4)) {
*buf.offset(i) = c;
i += 1;
}
Expand Down

0 comments on commit ae9d9ba

Please sign in to comment.