本文整理汇总了C++中boost::filesystem::path::root_path方法的典型用法代码示例。如果您正苦于以下问题:C++ path::root_path方法的具体用法?C++ path::root_path怎么用?C++ path::root_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::root_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: naive_uncomplete
boost::filesystem::path naive_uncomplete(boost::filesystem::path const path,
boost::filesystem::path const base) {
if (path.has_root_path()){
if (path.root_path() != base.root_path()) {
return path;
} else {
return naive_uncomplete(path.relative_path(), base.relative_path());
}
} else {
if (base.has_root_path()) {
throw "cannot uncomplete a path relative path from a rooted base";
} else {
typedef boost::filesystem::path::const_iterator path_iterator;
path_iterator path_it = path.begin();
path_iterator base_it = base.begin();
while ( path_it != path.end() && base_it != base.end() ) {
if (*path_it != *base_it) break;
++path_it; ++base_it;
}
boost::filesystem::path result;
for (; base_it != base.end(); ++base_it) {
result /= "..";
}
for (; path_it != path.end(); ++path_it) {
result /= *path_it;
}
return result;
}
}
}
示例2: MakePathRelative
boost::filesystem::path MultiresImagePlugin::MakePathRelative(boost::filesystem::path path, boost::filesystem::path base)
{
// Borrowed from: https://svn.boost.org/trac/boost/ticket/1976#comment:2
if (path.has_root_path())
{
if (path.root_path() != base.root_path())
{
return path;
}
else
{
return MakePathRelative(path.relative_path(), base.relative_path());
}
}
else
{
if (base.has_root_path())
{
ROS_WARN("Cannot uncomplete a path relative path from a rooted base.");
return path;
}
else
{
typedef boost::filesystem::path::const_iterator path_iterator;
path_iterator path_it = path.begin();
path_iterator base_it = base.begin();
while (path_it != path.end() && base_it != base.end())
{
if (*path_it != *base_it)
break;
++path_it;
++base_it;
}
boost::filesystem::path result;
for (; base_it != base.end(); ++base_it)
{
result /= "..";
}
for (; path_it != path.end(); ++path_it)
{
result /= *path_it;
}
return result;
}
}
}