4 #include "boost/filesystem/path.hpp" 5 #include "boost/filesystem/operations.hpp" 12 namespace bf = boost::filesystem;
13 bool resolveOneSymbolicLink(
std::string& fullPath) {
16 if (fullPath[0] !=
'/')
19 std::vector<std::string> pathElements =
edm::tokenize(fullPath,
"/");
20 for (
auto const&
path : pathElements) {
23 pathToResolve +=
path;
25 if (bf::is_symlink(bf::symlink_status(symLinkPath))) {
26 bf::path resolved = bf::read_symlink(symLinkPath);
29 if (!bf::exists(resolved)) {
33 auto begin = fullPath.begin();
34 auto end =
begin + pathToResolve.size();
36 if (resolvedPath[0] ==
'/') {
37 fullPath.replace(
begin,
end, resolvedPath);
39 fullPath.replace(
begin + 1,
end, resolvedPath);
51 bool found = resolveOneSymbolicLink(fullPath);
void resolveSymbolicLinks(std::string &fullPath)
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator