diff options
Diffstat (limited to 'Applications/Help/ManualSectionNode.cpp')
-rw-r--r-- | Applications/Help/ManualSectionNode.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Applications/Help/ManualSectionNode.cpp b/Applications/Help/ManualSectionNode.cpp new file mode 100644 index 0000000000..17e1ed3a51 --- /dev/null +++ b/Applications/Help/ManualSectionNode.cpp @@ -0,0 +1,26 @@ +#include "ManualSectionNode.h" +#include "ManualPageNode.h" +#include <AK/String.h> +#include <LibCore/CDirIterator.h> + +String ManualSectionNode::path() const +{ + return String::format("/usr/share/man/man%s", m_section.characters()); +} + +void ManualSectionNode::reify_if_needed() const +{ + if (m_reified) + return; + m_reified = true; + + CDirIterator dir_iter { path(), CDirIterator::Flags::SkipDots }; + + while (dir_iter.has_next()) { + String file_name = dir_iter.next_path(); + ASSERT(file_name.ends_with(".md")); + String page_name = file_name.substring(0, file_name.length() - 3); + NonnullOwnPtr<ManualNode> child = make<ManualPageNode>(*this, move(page_name)); + m_children.append(move(child)); + } +} |