Get actual path symlink is pointing to
Asked Answered
O

2

10

Given a symlink, I want to know to which directory this symlink is pointing. Does the Rust standard library offer something to find this out? I have only found unstable API functions so far.

Older answered 15/10, 2015 at 19:49 Comment(0)
M
14

It seems to me that you want fs::read_link:

Reads a symbolic link, returning the file that the link points to.

Magistracy answered 15/10, 2015 at 20:7 Comment(0)
A
9

You can use std::fs::canonicalize:

Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.

Armagnac answered 2/1, 2020 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.