|
|
@ -16,20 +16,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
struct MatchPathSeparator
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool operator()(char ch) const { return ch == '\\' || ch == '/'; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string getBasename(std::string const& pathname)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return std::string(
|
|
|
|
|
|
|
|
std::find_if(pathname.rbegin(), pathname.rend(), MatchPathSeparator()).base(), pathname.end());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool changeExtension(std::string& path, std::string_view ext)
|
|
|
|
bool changeExtension(std::string& path, std::string_view ext)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string::size_type pos = path.rfind('.');
|
|
|
|
std::string::size_type pos = path.rfind('.');
|
|
|
@ -40,6 +26,7 @@ bool changeExtension(std::string& path, std::string_view ext)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Misc::ResourceHelpers::changeExtensionToDds(std::string& path)
|
|
|
|
bool Misc::ResourceHelpers::changeExtensionToDds(std::string& path)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -106,7 +93,8 @@ std::string Misc::ResourceHelpers::correctResourcePath(
|
|
|
|
// fall back to a resource in the top level directory if it exists
|
|
|
|
// fall back to a resource in the top level directory if it exists
|
|
|
|
std::string fallback{ topLevelDirectories.front() };
|
|
|
|
std::string fallback{ topLevelDirectories.front() };
|
|
|
|
fallback += '\\';
|
|
|
|
fallback += '\\';
|
|
|
|
fallback += getBasename(correctedPath);
|
|
|
|
fallback += Misc::getFileName(correctedPath);
|
|
|
|
|
|
|
|
|
|
|
|
if (vfs->exists(fallback))
|
|
|
|
if (vfs->exists(fallback))
|
|
|
|
return fallback;
|
|
|
|
return fallback;
|
|
|
|
|
|
|
|
|
|
|
@ -114,7 +102,7 @@ std::string Misc::ResourceHelpers::correctResourcePath(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fallback = topLevelDirectories.front();
|
|
|
|
fallback = topLevelDirectories.front();
|
|
|
|
fallback += '\\';
|
|
|
|
fallback += '\\';
|
|
|
|
fallback += getBasename(origExt);
|
|
|
|
fallback += Misc::getFileName(origExt);
|
|
|
|
if (vfs->exists(fallback))
|
|
|
|
if (vfs->exists(fallback))
|
|
|
|
return fallback;
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|