How do you determine the path of the file that a symlink points to?
问题 In Linux, if you have a path to a file which you know is a symlink, how do you programmatically determine (in C or C++) the path to the file that it points to? 回答1: The readlink function. Do a man 2 readlink . This function is part of the Posix API, so it should work on almost any Unix. If the path starts with a '/' , then its an absolute symlink and you have the full absolute path of the file to which it refers (which may be another symbolic link, and you'll have to repeat the process again)