Implement path::join for initializer lists

This allows passing multiple path components to path::join
This commit is contained in:
Allan Odgaard
2013-02-12 09:52:38 +01:00
parent 6acafbe190
commit f05c76a882
2 changed files with 7 additions and 0 deletions

View File

@@ -178,6 +178,11 @@ namespace path
return !path.empty() && path[0] == '/' ? normalize(path) : normalize(base + "/" + path);
}
std::string join (std::initializer_list<std::string> const& components)
{
return normalize(text::join(components, "/"));
}
bool is_absolute (std::string const& path)
{
if(!path.empty() && path[0] == '/')

View File

@@ -21,6 +21,8 @@ namespace path
PUBLIC std::string join (std::string const& base, std::string const& path); // this will normalize the (resulting) path
PUBLIC std::string join (std::initializer_list<std::string> const& components);
PUBLIC bool is_absolute (std::string const& path);
PUBLIC bool is_child (std::string const& nonNormalizedChild, std::string const& nonNormalizedParent);
PUBLIC std::string with_tilde (std::string const& path); // /Users/me/foo.html.erb → ~/foo.html.erb