std::experimental::filesystem::read_symlink
Min standard notice:
Header: <experimental/filesystem>
If the path p refers to a symbolic link, returns a new path object which refers to the target of that symbolic link.
# Declarations
path read_symlink( const path& p );
path read_symlink( const path& p, error_code& ec );
(filesystem TS)
# Parameters
p: path to a symlinkec: out-parameter for error reporting in the non-throwing overload
# Return value
The target of the symlink (which may not necessarily exist).
# Example
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
// on a typical Linux system, /lib/libc.so.6 is a symlink
fs::path p = "/lib/libc.so.6";
if (exists(p) && is_symlink(p))
std::cout << p << " -> " << read_symlink(p) << '\n';
else
std::cout << p << " does not exist or is not a symlink\n";
}