-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree displayer.cpp
More file actions
37 lines (32 loc) · 839 Bytes
/
tree displayer.cpp
File metadata and controls
37 lines (32 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "tree displayer.h"
#include "directory tree.h"
#include <iostream>
#include <string>
#include <cstddef>
void TreeDisplayer::printPath(const fs::path& path)
{
std::cout << path.string();
}
void TreeDisplayer::printFilename(const fs::path& path)
{
std::cout << path.filename().string();
}
void TreeDisplayer::printChildren(const DirectoryTree::Node* node)
{
for (auto const& entry_it : fs::directory_iterator(node->path))
{
std::cout << " ";
printFilename(entry_it);
std::cout << '\n';
}
}
void TreeDisplayer::printCurrentPath(const DirectoryTree& tree)
{
printPath(tree.iterator().get()->path);
}
void TreeDisplayer::displayCurrent(const DirectoryTree& tree)
{
printFilename(tree.m_iterator.get()->path);
std::cout << '\n';
printChildren(tree.m_iterator.get());
}