diff --git a/Userland/Applications/SpaceAnalyzer/Tree.cpp b/Userland/Applications/SpaceAnalyzer/Tree.cpp index bfc7909a649..eb6258a0c0f 100644 --- a/Userland/Applications/SpaceAnalyzer/Tree.cpp +++ b/Userland/Applications/SpaceAnalyzer/Tree.cpp @@ -128,3 +128,13 @@ HashMap TreeNode::populate_filesize_tree(Vector& mounts, Fu update_totals(); return error_accumulator; } + +Optional TreeNode::child_with_name(DeprecatedString name) const +{ + for (auto& child : *m_children) { + if (child.name() == name) + return child; + } + + return {}; +} diff --git a/Userland/Applications/SpaceAnalyzer/Tree.h b/Userland/Applications/SpaceAnalyzer/Tree.h index ee63facaedf..377bb4fb1f0 100644 --- a/Userland/Applications/SpaceAnalyzer/Tree.h +++ b/Userland/Applications/SpaceAnalyzer/Tree.h @@ -32,6 +32,7 @@ public: return 0; } TreeNode const& child_at(size_t i) const { return m_children->at(i); } + Optional child_with_name(DeprecatedString name) const; void sort_children_by_area() const; HashMap populate_filesize_tree(Vector& mounts, Function on_progress);