1
Fork 0
Fix `read_link` to also be able to read the target of junctions on Windows.
Also the path returned should not include a NT namespace, and there were
some problems with permissions.
This commit is contained in:
Paul Dicker 2016-02-13 20:44:37 +01:00
parent 5367776bd1
commit 6403f913dd
3 changed files with 92 additions and 58 deletions

View file

@ -2151,6 +2151,26 @@ mod tests {
"foo");
}
#[test]
fn read_link() {
if cfg!(windows) {
// directory symlink
assert_eq!(check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
r"C:\ProgramData");
// junction
assert_eq!(check!(fs::read_link(r"C:\Users\Default User")).to_str().unwrap(),
r"C:\Users\Default");
// junction with special permissions
assert_eq!(check!(fs::read_link(r"C:\Documents and Settings\")).to_str().unwrap(),
r"C:\Users");
}
let tmpdir = tmpdir();
let link = tmpdir.join("link");
if !got_symlink_permission(&tmpdir) { return };
check!(symlink_file(&"foo", &link));
assert_eq!(check!(fs::read_link(&link)).to_str().unwrap(), "foo");
}
#[test]
fn readlink_not_symlink() {
let tmpdir = tmpdir();