I want to check whether two paths are to the same file/directory with Boost.Filesystem.
For example, "/bin" and "/./bin" are to the same directory, but the following code doesn't work as intended.
namespace fs = boost::filesystem;
fs::path p1{"/bin"}, p2{"/./bin"};
if(p1 == p2){
std::cout << "Equal" << std::endl;
}else{
std::cout << "Not equal" << std::endl;
}
The output of this is "Not equal".
How can I check whether two paths are to the same file/directory? Could you tell me this?
Thanks.
You should use equivalent function, since comparison operators for paths compare only lexicographical order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With