Fixed handling of relative paths in configuration files (#69)
This commit is contained in:
@@ -317,4 +317,17 @@ std::string path_to_url(const std::filesystem::path &p)
|
||||
return fmt::format("{}", fmt::join(path_tokens, "/"));
|
||||
}
|
||||
|
||||
std::filesystem::path ensure_path_is_absolute(
|
||||
const std::filesystem::path &p, const std::filesystem::path &root)
|
||||
{
|
||||
if (p.is_absolute())
|
||||
return p;
|
||||
|
||||
auto result = root / p;
|
||||
result = result.lexically_normal();
|
||||
result.make_preferred();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace clanguml::util
|
||||
|
||||
@@ -250,4 +250,17 @@ std::size_t hash_seed(std::size_t seed);
|
||||
*/
|
||||
std::string path_to_url(const std::filesystem::path &p);
|
||||
|
||||
/**
|
||||
* @brief Ensure path is absolute.
|
||||
*
|
||||
* If path is absolute, return the p. If path is not absolute, make it
|
||||
* absolute with respect to root directory.
|
||||
*
|
||||
* @param p Path to modify
|
||||
* @param root Root against which the path should be made absolute
|
||||
* @return Absolute path
|
||||
*/
|
||||
std::filesystem::path ensure_path_is_absolute(const std::filesystem::path &p,
|
||||
const std::filesystem::path &root = std::filesystem::current_path());
|
||||
|
||||
} // namespace clanguml::util
|
||||
Reference in New Issue
Block a user