获取符号链接指向的实际路径
Get actual path symlink is pointing to
给定一个符号链接,我想知道这个符号链接指向哪个目录。 Rust 标准库是否提供了一些东西来找出这个问题?
我目前只找到 unstable API functions。
我觉得你想要 fs::read_link
:
Reads a symbolic link, returning the file that the link points to.
您可以使用 std::fs::canonicalize
:
Returns the canonical, absolute form of a path with all intermediate
components normalized and symbolic links resolved.
给定一个符号链接,我想知道这个符号链接指向哪个目录。 Rust 标准库是否提供了一些东西来找出这个问题? 我目前只找到 unstable API functions。
我觉得你想要 fs::read_link
:
Reads a symbolic link, returning the file that the link points to.
您可以使用 std::fs::canonicalize
:
Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.