Boost C++11 provides a module called filesystem that can be used to resolve the symlinks of a file path. Here's an example:
#include <boost/filesystem.hpp>
#include <iostream>
int main() {
boost::filesystem::path path("/some/symlink/path");
path = boost::filesystem::canonical(path);
std::cout << path << std::endl;
return 0;
}
In this example, the path "/some/symlink/path" is first converted to a boost::filesystem::path object. Then, the canonical() function is called to resolve any symlinks in the path. Finally, the resolved path is printed to the console.
Note that resolving symlinks may result in a different path than the original one, so it's important to check if the resolved path is the expected one before using it.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-10-31 11:00:00 +0000
Seen: 17 times
Last updated: Feb 26 '23
What is the method to get a printable output of a C++11 time_point?
What is the process of redefining a c++ macro with fewer parameters?
How can a list be sorted alphabetically within a console application?
What distinguishes the jsonlite and rjson packages from each other at their core?
How can the issue of accessing a member within an address that is misaligned be resolved at runtime?
Does a C++ constructor get passed down through inheritance?
What is the difference between deallocating memory in C and deallocating memory in C++?