MCPcopy Create free account
hub / github.com/USBGuard/usbguard / countPathComponents

Function countPathComponents

src/Common/Utility.cpp:459–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457 }
458
459 std::size_t countPathComponents(const std::string& path)
460 {
461 bool was_component = false;
462 std::size_t count = 0;
463
464 for (std::size_t i = 0; i < path.size(); ++i) {
465 const char c = path[i];
466
467 if (c == '/') {
468 if (was_component) {
469 ++count;
470 was_component = false;
471 }
472 }
473 else {
474 was_component = true;
475 }
476 }
477
478 return count;
479 }
480
481 std::string normalizePath(const std::string& path)
482 {

Callers 4

parseFromFileMethod · 0.85
umockdevRemoveByFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected