24 lines
460 B
C++
24 lines
460 B
C++
|
|
#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
|