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

Method GetDirectory

storage/path/path.cpp:45–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45std::string Path::GetDirectory(const std::string& filepath)
46{
47 std::string path = filepath;
48 if (path.size() > 1 && path[path.size() - 1] == '/')
49 path.resize(path.size() - 1);
50 size_t last_slash = path.rfind('/');
51 if (last_slash == std::string::npos)
52 return ".";
53 if (last_slash == 0)
54 return "/";
55
56 return path.substr(0, last_slash);
57}
58
59std::string Path::ToAbsolute(const std::string& filepath)
60{

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