MCPcopy Create free account
hub / github.com/chen3feng/toft / GetBaseName

Method GetBaseName

storage/path/path.cpp:24–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24std::string Path::GetBaseName(const std::string& filepath)
25{
26 std::string path = filepath;
27 if (path.size() > 1 && path[path.size() - 1] == '/')
28 path.resize(path.size() - 1);
29 size_t last_slash = path.rfind('/');
30 if (last_slash == std::string::npos)
31 last_slash = 0;
32 else
33 ++last_slash;
34 return path.substr(last_slash);
35}
36
37std::string Path::GetExtension(const std::string& filepath)
38{

Callers

nothing calls this directly

Calls 4

resizeMethod · 0.80
rfindMethod · 0.80
substrMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected