--------------------------------- Directory::GetMountedChildRecursive
| 472 | // Directory::GetMountedChildRecursive |
| 473 | // |
| 474 | Entry* Directory::GetMountedChildRecursive(std::string& path) const |
| 475 | { |
| 476 | // split off the next search directory and figure out if this is the last one |
| 477 | std::string searchName = FileUtil::SplitFirstDirectory(path); |
| 478 | |
| 479 | bool isFinalEntry = searchName.empty(); |
| 480 | if (isFinalEntry) |
| 481 | { |
| 482 | searchName = path; |
| 483 | } |
| 484 | |
| 485 | // try finding the child |
| 486 | auto childIt = std::find_if(m_pChildren.begin(), m_pChildren.end(), [&searchName](Entry const* const entry) |
| 487 | { |
| 488 | return entry->GetNameOnly() == searchName; |
| 489 | }); |
| 490 | |
| 491 | if (childIt == m_pChildren.cend()) // child not found |
| 492 | { |
| 493 | return nullptr; |
| 494 | } |
| 495 | |
| 496 | Entry* const childEntry = *childIt; |
| 497 | |
| 498 | if (!isFinalEntry) // if we are supposed to find a child of the found entry, make sure we have a directory and repeat the search in its children |
| 499 | { |
| 500 | if (childEntry->GetType() == Entry::EntryType::ENTRY_FILE) |
| 501 | { |
| 502 | return nullptr; |
| 503 | } |
| 504 | |
| 505 | return static_cast<Directory*>(childEntry)->GetMountedChildRecursive(path); |
| 506 | } |
| 507 | |
| 508 | // we found the final entry |
| 509 | return childEntry; |
| 510 | } |
| 511 | |
| 512 | |
| 513 | } // namespace core |