| 290 | |
| 291 | template <typename It> |
| 292 | Entry* FindEntry(It it, It end, size_t* nconsumed) { |
| 293 | size_t consumed = 0; |
| 294 | Entry* entry = &root; |
| 295 | |
| 296 | for (; it != end; ++it) { |
| 297 | const std::string& part = *it; |
| 298 | DCHECK(entry->is_dir()); |
| 299 | Entry* child = entry->as_dir().Find(part); |
| 300 | if (child == nullptr) { |
| 301 | // Partial find only |
| 302 | break; |
| 303 | } |
| 304 | ++consumed; |
| 305 | entry = child; |
| 306 | if (entry->is_file()) { |
| 307 | // Cannot go any further |
| 308 | break; |
| 309 | } |
| 310 | // Recurse |
| 311 | } |
| 312 | *nconsumed = consumed; |
| 313 | return entry; |
| 314 | } |
| 315 | |
| 316 | // Find an entry, allowing partial matching |
| 317 | Entry* FindEntry(const std::vector<std::string>& parts, size_t* nconsumed) { |