mirror of https://github.com/OpenMW/openmw.git
Move getFileExtension to common header and use instead of repeating same code
parent
c2df0949e2
commit
6817282097
@ -0,0 +1,19 @@
|
||||
#ifndef OPENMW_COMPONENTS_MISC_PATHHELPERS_H
|
||||
#define OPENMW_COMPONENTS_MISC_PATHHELPERS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
inline std::string_view getFileExtension(std::string_view file)
|
||||
{
|
||||
if (auto extPos = file.find_last_of('.'); extPos != std::string::npos)
|
||||
{
|
||||
file.remove_prefix(extPos + 1);
|
||||
return file;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue