Alex Rivera | Logout

Resolve symlinks with boost filesystem

Asked 2011-12-07T15:36:52.043
11

I expect there is a simple way of doing this but I haven't been able to uncover this even with some intense googling.

How can I use boost::filesystem to find the location a symlink ( on *nix systems ) points to?

Edit
Report

1 Answer

6

You can use the read_symlink() function of Version 3:

path read_symlink(const path& p);
path read_symlink(const path& p, system::error_code& ec);

Returns: If p resolves to a symbolic link, a path object containing the contents of that symbolic link. Otherwise an empty path object.

Throws: As specified in Error reporting. [Note: It is an error if p does not resolve to a symbolic link. -- end note]

answered 2011-12-07T15:50:45.387

Your Answer