mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:22:46 +00:00 
			
		
		
		
	 1682f0b760
			
		
	
	
		1682f0b760
		
	
	
	
	
		
			
			SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
		
			
				
	
	
		
			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/LexicalPath.h>
 | |
| #include <AK/QuickSort.h>
 | |
| #include <AK/String.h>
 | |
| #include <LibCore/DirIterator.h>
 | |
| 
 | |
| String ManualSectionNode::path() const
 | |
| {
 | |
|     return String::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<String> 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;
 | |
| }
 |