mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add EnginePaths::parsePath & update generation.load_structure
This commit is contained in:
parent
4f882a3ca3
commit
aa1fb26ea5
4 changed files with 18 additions and 7 deletions
|
|
@ -162,15 +162,23 @@ void EnginePaths::setContentPacks(std::vector<ContentPack>* contentPacks) {
|
|||
this->contentPacks = contentPacks;
|
||||
}
|
||||
|
||||
std::tuple<std::string, std::string> EnginePaths::parsePath(std::string_view path) {
|
||||
size_t separator = path.find(':');
|
||||
if (separator == std::string::npos) {
|
||||
return {"", std::string(path)};
|
||||
}
|
||||
auto prefix = std::string(path.substr(0, separator));
|
||||
auto filename = std::string(path.substr(separator + 1));
|
||||
return {prefix, filename};
|
||||
}
|
||||
|
||||
std::filesystem::path EnginePaths::resolve(
|
||||
const std::string& path, bool throwErr
|
||||
) {
|
||||
size_t separator = path.find(':');
|
||||
if (separator == std::string::npos) {
|
||||
auto [prefix, filename] = EnginePaths::parsePath(path);
|
||||
if (prefix.empty()) {
|
||||
throw files_access_error("no entry point specified");
|
||||
}
|
||||
std::string prefix = path.substr(0, separator);
|
||||
std::string filename = path.substr(separator + 1);
|
||||
filename = toCanonic(fs::u8path(filename)).u8string();
|
||||
|
||||
if (prefix == "res" || prefix == "core") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue