| 66 | } |
| 67 | |
| 68 | std::string SliceAbstractPath(const std::string& s, int offset, int length, char sep) { |
| 69 | if (offset < 0 || length < 0) { |
| 70 | return ""; |
| 71 | } |
| 72 | std::vector<std::string> components = SplitAbstractPath(s, sep); |
| 73 | if (offset >= static_cast<int>(components.size())) { |
| 74 | return ""; |
| 75 | } |
| 76 | const auto end = std::min(static_cast<size_t>(offset) + length, components.size()); |
| 77 | std::stringstream combined; |
| 78 | for (auto i = static_cast<size_t>(offset); i < end; i++) { |
| 79 | combined << components[i]; |
| 80 | if (i < end - 1) { |
| 81 | combined << sep; |
| 82 | } |
| 83 | } |
| 84 | return combined.str(); |
| 85 | } |
| 86 | |
| 87 | int GetAbstractPathDepth(std::string_view path) { |
| 88 | if (path.empty()) { |