I am trying to create relative paths using boost.
My initial plan:
string base_directory; // input boost::filesystem::path base_path; string other_directory; // input boost::filesystem::path other_path; // assume base_path is absolute - did that already (using complete() // if path is relative, to root it in the current directory) -> base_directory = base_path.string(); if (other_path.empty()) other_directory = base_directory; else { other_path = boost::filesystem::path(other_directory); if(!other_path.is_complete()) { other_path = base_path / other_path; other_directory = other_path.string(); } if(!boost::filesystem::exists(boost::filesystem::path(other_path))) { boost::filesystem::create_directory(other_path); } }
This works fine if other_directory is an absolute or just a name (or relative internal in base_directory).
But if I try to put ".." or "../other", I end up creating weird constructs like "c: \ test .." or "c: \ test .. \ other"
How can I properly create relative paths, preferably using boost? I tried looking in the documentation ... without positive success.
I use Windows (my preference for boost is that it should be multi-platform and I'm already dependent on it)
Edit: I increased 1.47
Thanks for any suggestion.
source share