Boost::filesystem : possible addition

Hello, I've always wanted some functionality to determine the relative path between two paths. Maybe something like this can be added to the convinience.hpp or otherwise: fs::path relative_path_of(fs::path const &base, fs::path const &full) { std::string fullStr = full.string(); std::string baseStr = base.string() + "/"; // add a slash so that it returns the relative path boost::erase_first(fullStr, baseStr); return fs::path(fullStr); } Cheers, Georgios

I've always wanted some functionality to determine the relative path between two paths. Maybe something like this can be added to the convinience.hpp or otherwise:
fs::path relative_path_of(fs::path const &base, fs::path const &full) { std::string fullStr = full.string(); std::string baseStr = base.string() + "/"; // add a slash so that it returns the relative path
boost::erase_first(fullStr, baseStr); return fs::path(fullStr); }
The bcp utility needed something similar, and I had to hack my own version like you did, of course it's probably not possible to write a truly portable version, but it sure would be useful all the same. John.
participants (2)
-
Georgios Diamantopoulos
-
John Maddock