mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-11-29 16:14:16 +01:00
Fix path building
This commit is contained in:
parent
9f5bf0b042
commit
bae8254d22
@ -234,15 +234,26 @@ std::string resolvePath (std::string_view const path_)
|
|||||||
/// \param args_ Child component
|
/// \param args_ Child component
|
||||||
std::string buildPath (std::string_view const cwd_, std::string_view const args_)
|
std::string buildPath (std::string_view const cwd_, std::string_view const args_)
|
||||||
{
|
{
|
||||||
|
std::string path;
|
||||||
|
|
||||||
// absolute path
|
// absolute path
|
||||||
if (args_[0] == '/')
|
if (args_[0] == '/')
|
||||||
return std::string (args_);
|
path = std::string (args_);
|
||||||
|
// relative path
|
||||||
|
else
|
||||||
|
path = std::string (cwd_) + '/' + std::string (args_);
|
||||||
|
|
||||||
// root directory
|
// coalesce consecutive slashes
|
||||||
if (cwd_.size () == 1)
|
auto it = std::begin (path);
|
||||||
return std::string (cwd_) + std::string (args_);
|
while (it != std::end (path))
|
||||||
|
{
|
||||||
|
if (it != std::begin (path) && *it == '/' && *std::prev (it) == '/')
|
||||||
|
it = path.erase (it);
|
||||||
|
else
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
return std::string (cwd_) + '/' + std::string (args_);
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Build resolved path from a parent and child
|
/// \brief Build resolved path from a parent and child
|
||||||
|
Loading…
Reference in New Issue
Block a user