Get actual path symlink is pointing to

别等时光非礼了梦想. 提交于 2020-02-03 10:35: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.


回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!