MCPcopy Create free account
hub / github.com/apple/foundationdb / popPath

Function popPath

flow/Platform.actor.cpp:2494–2520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2492}
2493
2494std::string popPath(const std::string& path) {
2495 int i = path.size() - 1;
2496 // Skip over any trailing separators
2497 while (i >= 0 && path[i] == CANONICAL_PATH_SEPARATOR) {
2498 --i;
2499 }
2500 // Skip over non separators
2501 while (i >= 0 && path[i] != CANONICAL_PATH_SEPARATOR) {
2502 --i;
2503 }
2504 // Skip over trailing separators again
2505 bool foundSeparator = false;
2506 while (i >= 0 && path[i] == CANONICAL_PATH_SEPARATOR) {
2507 --i;
2508 foundSeparator = true;
2509 }
2510
2511 if (foundSeparator) {
2512 ++i;
2513 } else {
2514 // If absolute then we popped off the only path component so return "/"
2515 if (!path.empty() && path.front() == CANONICAL_PATH_SEPARATOR) {
2516 return "/";
2517 }
2518 }
2519 return path.substr(0, i + 1);
2520}
2521
2522std::string abspath(std::string const& path_, bool resolveLinks, bool mustExist) {
2523 if (path_.empty()) {

Callers 10

abspathFunction · 0.70
parentDirectoryFunction · 0.70
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50
callMethod · 0.50

Calls 4

frontMethod · 0.80
substrMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 8

callMethod · 0.40
callMethod · 0.40
callMethod · 0.40
callMethod · 0.40
callMethod · 0.40
callMethod · 0.40
callMethod · 0.40
callMethod · 0.40