本文整理汇总了C++中utils::fs::path::to_absolute方法的典型用法代码示例。如果您正苦于以下问题:C++ path::to_absolute方法的具体用法?C++ path::to_absolute怎么用?C++ path::to_absolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils::fs::path
的用法示例。
在下文中一共展示了path::to_absolute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PRE
/// Returns the test suite name for the current directory.
///
/// \return The identifier of the current test suite.
std::string
layout::test_suite_for_path(const fs::path& path)
{
std::string test_suite;
if (path.is_absolute())
test_suite = path.str();
else
test_suite = path.to_absolute().str();
PRE(!test_suite.empty() && test_suite[0] == '/');
std::replace(test_suite.begin(), test_suite.end(), '/', '_');
test_suite.erase(0, 1);
return test_suite;
}
示例2: path_input
/// Locates a file in the PATH.
///
/// \param name The file to locate.
///
/// \return The path to the located file or none if it was not found. The
/// returned path is always absolute.
optional< fs::path >
fs::find_in_path(const char* name)
{
const optional< std::string > current_path = utils::getenv("PATH");
if (!current_path || current_path.get().empty())
return none;
std::istringstream path_input(current_path.get() + ":");
std::string path_component;
while (std::getline(path_input, path_component, ':').good()) {
const fs::path candidate = path_component.empty() ?
fs::path(name) : (fs::path(path_component) / name);
if (exists(candidate)) {
if (candidate.is_absolute())
return utils::make_optional(candidate);
else
return utils::make_optional(candidate.to_absolute());
}
}
return none;
}
示例3:
/// Gets the absolute path to the test program.
///
/// \return The absolute path to the test program binary.
const fs::path
model::test_program::absolute_path(void) const
{
const fs::path full_path = _pimpl->root / _pimpl->binary;
return full_path.is_absolute() ? full_path : full_path.to_absolute();
}