blob: 7484eb84d442ec585f293adf9c818dbe01cf6fbf (
plain) (
blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <pland/syscall.h>
#include <knob/format.h>
#include <knob/file.h>
#include <knob/user.h>
#define MAX_DIR_ENTRIES 20
void main(const char *arg) {
uint8_t dn;
const char *path = remove_prefix(arg, &dn);
tell_user_sz("Directory info for ");
tell_user_sz(*arg ? arg : "drive root");
tell_user_sz("\n");
_dir_info_entry infos[MAX_DIR_ENTRIES];
uint8_t count = _enumerate_dir(dn, path, infos, MAX_DIR_ENTRIES);
tell_user_sz(
count == MAX_DIR_ENTRIES
? "Truncated to 20 entries.\n\n"
: "\n"
);
uint32_t total_size = 0;
if (!count)
tell_user_sz("(none)\n");
for (uint8_t i = 0; i < count; ++i) {
tell_user_sz(infos[i].name);
tell_user_sz(": ");
if (infos[i].is_dir)
tell_user_sz("dir");
else {
char nbuf[11];
itosz(infos[i].size, nbuf);
tell_user_sz(nbuf);
tell_user_sz(" bytes");
total_size += infos[i].size;
}
tell_user_sz("\n");
}
tell_user_sz("\nTotal size without subdirectories: ");
char nbuf[11];
itosz(total_size, nbuf);
tell_user_sz(nbuf);
tell_user_sz(" bytes\n");
}
|