add io::path.normalized()

This commit is contained in:
MihailRis
2025-02-04 14:58:41 +03:00
parent 1ec8f89599
commit 59f46ad530
5 changed files with 39 additions and 35 deletions
-26
View File
@@ -25,32 +25,6 @@ static inline io::path EXPORT_FOLDER = "export";
static inline io::path CONTROLS_FILE = "controls.toml";
static inline io::path SETTINGS_FILE = "settings.toml";
static io::path toCanonic(io::path path) {
std::stack<std::string> parts;
path = std::filesystem::u8path(path.string()).lexically_normal().string();
do {
parts.push(path.name());
path = path.parent();
} while (!path.empty());
path = "";
while (!parts.empty()) {
const std::string part = parts.top();
parts.pop();
if (part == ".") {
continue;
}
if (part == "..") {
throw files_access_error("entry point reached");
}
path = path / part;
}
return path;
}
void EnginePaths::prepare() {
io::set_device("res", std::make_shared<io::StdfsDevice>(resourcesFolder, false));
io::set_device("user", std::make_shared<io::StdfsDevice>(userFilesFolder));