mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 12:15:07 +00:00

We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "ManualSectionNode.h"
|
|
#include "ManualPageNode.h"
|
|
#include <AK/DeprecatedString.h>
|
|
#include <AK/LexicalPath.h>
|
|
#include <AK/QuickSort.h>
|
|
#include <LibCore/DirIterator.h>
|
|
|
|
DeprecatedString ManualSectionNode::path() const
|
|
{
|
|
return DeprecatedString::formatted("/usr/share/man/man{}", m_section);
|
|
}
|
|
|
|
void ManualSectionNode::reify_if_needed() const
|
|
{
|
|
if (m_reified)
|
|
return;
|
|
m_reified = true;
|
|
|
|
Core::DirIterator dir_iter { path(), Core::DirIterator::Flags::SkipDots };
|
|
|
|
Vector<DeprecatedString> page_names;
|
|
while (dir_iter.has_next()) {
|
|
LexicalPath lexical_path(dir_iter.next_path());
|
|
if (lexical_path.extension() != "md")
|
|
continue;
|
|
page_names.append(lexical_path.title());
|
|
}
|
|
|
|
quick_sort(page_names);
|
|
|
|
for (auto& page_name : page_names)
|
|
m_children.append(make<ManualPageNode>(*this, move(page_name)));
|
|
}
|
|
|
|
void ManualSectionNode::set_open(bool open)
|
|
{
|
|
if (m_open == open)
|
|
return;
|
|
m_open = open;
|
|
}
|