Fixes #28528
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:
parent
5367776bd1
commit
6403f913dd
3 changed files with 92 additions and 58 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue