问题
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.
回答1:
It seems to me that you want fs::read_link:
Reads a symbolic link, returning the file that the link points to.
回答2:
You can use std::fs::canonicalize:
Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.
来源:https://stackoverflow.com/questions/33157267/get-actual-path-symlink-is-pointing-to