Finally I used a copy of the boost v1.55 code to solve that issue.
inline bool is_absolute(const bfs::path p)
{
#if defined(WIN32) || defined(WIN64)
return p.has_root_name() && p.has_root_directory();
#else
return p.has_root_directory();
#endif
}
inline bfs::path absolute(const bfs::path& p, const bfs::path& base=bfs::current_path())
{
// recursively calling absolute is sub-optimal, but is sure and simple
bfs::path abs_base(is_absolute(base) ? base : absolute(base));
// store expensive to compute values that are needed multiple times
bfs::path p_root_name (p.root_name());
bfs::path base_root_name (abs_base.root_name());
bfs::path p_root_directory (p.root_directory());
if (p.empty())
{
return abs_base;
}
if (!p_root_name.empty()) // p.has_root_name()
{
if (p_root_directory.empty()) // !p.has_root_directory()
return p_root_name / abs_base.root_directory()
/ abs_base.relative_path() / p.relative_path();
// p is absolute, so fall through to return p at end of block
}
else if (!p_root_directory.empty()) // p.has_root_directory()
{
return base_root_name / p;
}
else
{
return abs_base / p;
}
return p; // p.is_absolute() is true
}