Add EnsureExtension
This commit is contained in:
@@ -226,4 +226,18 @@ namespace OpenVulkano
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
std::string FsUtils::EnsureExtension(const std::string& fileName, const std::string_view& extension)
|
||||
{
|
||||
if (!extension.empty() && !Utils::EndsWith(fileName, extension))
|
||||
{
|
||||
std::string name;
|
||||
name.reserve(fileName.length() + 2 + extension.length());
|
||||
name += fileName;
|
||||
if (extension[0] != '.') name += ".";
|
||||
name += std::string(extension);
|
||||
return name;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user