mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 01:07:43 +00:00
Add ProjectPath::getPathComponents()
This commit is contained in:
2
hecl/extern/Athena
vendored
2
hecl/extern/Athena
vendored
Submodule hecl/extern/Athena updated: fddb684e26...7da7bd751d
2
hecl/extern/libBoo
vendored
2
hecl/extern/libBoo
vendored
Submodule hecl/extern/libBoo updated: 939c0250be...c96f961c4d
@@ -891,6 +891,77 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Build vector of project-relative directory/file components
|
||||||
|
* @return Vector of path components
|
||||||
|
*/
|
||||||
|
std::vector<HECL::SystemString> getPathComponents() const
|
||||||
|
{
|
||||||
|
std::vector<HECL::SystemString> ret;
|
||||||
|
if (m_relPath.empty())
|
||||||
|
return ret;
|
||||||
|
auto it = m_relPath.cbegin();
|
||||||
|
if (*it == _S('/'))
|
||||||
|
{
|
||||||
|
ret.push_back(_S("/"));
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
HECL::SystemString comp;
|
||||||
|
for (; it != m_relPath.cend() ; ++it)
|
||||||
|
{
|
||||||
|
if (*it == _S('/'))
|
||||||
|
{
|
||||||
|
if (comp.empty())
|
||||||
|
continue;
|
||||||
|
ret.push_back(std::move(comp));
|
||||||
|
comp.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
comp += *it;
|
||||||
|
}
|
||||||
|
if (comp.size())
|
||||||
|
ret.push_back(std::move(comp));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Build vector of project-relative directory/file components
|
||||||
|
* @return Vector of path components encoded as UTF8
|
||||||
|
*/
|
||||||
|
std::vector<std::string> getPathComponentsUTF8() const
|
||||||
|
{
|
||||||
|
#if HECL_UCS2
|
||||||
|
const std::string& relPath = m_utf8RelPath;
|
||||||
|
#else
|
||||||
|
const std::string& relPath = m_relPath;
|
||||||
|
#endif
|
||||||
|
std::vector<std::string> ret;
|
||||||
|
if (relPath.empty())
|
||||||
|
return ret;
|
||||||
|
auto it = relPath.cbegin();
|
||||||
|
if (*it == '/')
|
||||||
|
{
|
||||||
|
ret.push_back(_S("/"));
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
std::string comp;
|
||||||
|
for (; it != relPath.cend() ; ++it)
|
||||||
|
{
|
||||||
|
if (*it == _S('/'))
|
||||||
|
{
|
||||||
|
if (comp.empty())
|
||||||
|
continue;
|
||||||
|
ret.push_back(std::move(comp));
|
||||||
|
comp.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
comp += *it;
|
||||||
|
}
|
||||||
|
if (comp.size())
|
||||||
|
ret.push_back(std::move(comp));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Access fully-canonicalized absolute path in UTF-8
|
* @brief Access fully-canonicalized absolute path in UTF-8
|
||||||
* @return Absolute path reference
|
* @return Absolute path reference
|
||||||
|
|||||||
Reference in New Issue
Block a user