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

Method umockdevGetChildrenBySysfsPath

src/Library/UMockdevDeviceManager.cpp:380–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378 }
379
380 std::vector<std::string> UMockdevDeviceManager::umockdevGetChildrenBySysfsPath(const std::string& sysfs_path)
381 {
382 std::vector<std::string> children;
383 auto it = _sysfs_path_map.find(sysfs_path);
384
385 if (it == _sysfs_path_map.cend()) {
386 throw Exception("UMockdevDeviceManager", sysfs_path, "cannot list children for undefined device");
387 }
388
389 const auto child_component_count = countPathComponents(sysfs_path) + 1;
390 ++it;
391
392 while (it != _sysfs_path_map.cend()) {
393 if (!hasPrefix(it->first, sysfs_path)) {
394 break;
395 }
396 else {
397 if (countPathComponents(it->first) == child_component_count) {
398 children.push_back(it->first);
399 }
400 }
401
402 ++it;
403 }
404
405 return children;
406 }
407
408 /*
409 * Set authorized=1 and add child devices.

Callers

nothing calls this directly

Calls 3

ExceptionFunction · 0.85
countPathComponentsFunction · 0.85
hasPrefixFunction · 0.85

Tested by

no test coverage detected