Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,30 @@ namespace util

std::string SanitizeTexture(const std::string& a_path)
{
static const srell::regex slashExpr("/+|\\\\+");
static const srell::regex leadingSlashExpr("^\\\\+");
static const srell::regex texturesExpr(R"(.*?[^\s]textures\\|^textures\\)", srell::regex::icase);

auto path = string::tolower(a_path);

path = srell::regex_replace(path, srell::regex("/+|\\\\+"), "\\");
path = srell::regex_replace(path, srell::regex("^\\\\+"), "");
path = srell::regex_replace(path, srell::regex(R"(.*?[^\s]textures\\|^textures\\)", srell::regex::icase), "");
path = srell::regex_replace(path, slashExpr, "\\");
path = srell::regex_replace(path, leadingSlashExpr, "");
path = srell::regex_replace(path, texturesExpr, "");

return path;
}

std::string SanitizeModel(const std::string& a_path)
{
static const srell::regex slashExpr("/+|\\\\+");
static const srell::regex leadingSlashExpr("^\\\\+");
static const srell::regex meshesExpr(R"(.*?[^\s]meshes\\|^meshes\\)", srell::regex::icase);

auto path = string::tolower(a_path);

path = srell::regex_replace(path, srell::regex("/+|\\\\+"), "\\");
path = srell::regex_replace(path, srell::regex("^\\\\+"), "");
path = srell::regex_replace(path, srell::regex(R"(.*?[^\s]meshes\\|^meshes\\)", srell::regex::icase), "");
path = srell::regex_replace(path, slashExpr, "\\");
path = srell::regex_replace(path, leadingSlashExpr, "");
path = srell::regex_replace(path, meshesExpr, "");

return path;
}
Expand Down