1
0
Fork 0

source/System/File.cpp: move path stuff to Path.cpp

This commit is contained in:
Henrik Hautakoski 2020-01-10 00:45:11 +01:00
parent 66f3bb30d9
commit 1a218532c0
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
8 changed files with 50 additions and 30 deletions

24
source/System/Path.cpp Normal file
View file

@ -0,0 +1,24 @@
#include <Spectre/System/Path.h>
namespace sp {
std::string Path::getBasename(const std::string& path)
{
size_t p = path.find_last_of('/');
if (p == std::string::npos)
return path;
return path.substr(p + 1);
}
std::string Path::getExtension(const std::string& path)
{
std::string base_name = getBasename(path);
size_t p = base_name.find_first_of('.');
if (p == std::string::npos)
return "";
return base_name.substr(p + 1);
}
} // namespace sp