-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandDIR.cpp
37 lines (33 loc) · 757 Bytes
/
CommandDIR.cpp
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 "UDF.hpp"
#include <iostream>
#include "CommandDIR.hpp"
#include "FileSystem.hpp"
bool CommandDIR::execute(FileSystem &tree, UDF&) {
auto infos = tree.getDirInfo();
for (const FileIdentifier::InfoDir *info : infos) {
uint64_t size = info->length;
size /= 1024;
const char *unit = "KB";
if (size > 2000) {
size /= 1024;
unit = "MB";
}
if (size > 2000) {
size /= 1024;
unit = "GB";
}
if (info->hidden)
std::cout << "<hide>";
std::cout << "\t" << info->name
<< "\t\t\t";
if (info->isDir)
std::cout << "<dir>";
else {
std::cout.precision(3);
std::cout << size << unit;
}
std::cout << "\t" << info->date.toString() << std::endl;
}
std::cout << "Command dir executed." << std::endl;
return true;
}