blob: 64f0ddbe6378c973e0c7cfa8c95a74c00c65c044 (
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
|
#include <libterm/terminal.h>
#include <knob/block.h>
#include <knob/file.h>
#define MAX_NAME_LEN 15
#define COLUMN_SEP " - "
void main(const char *path) {
uint32_t count;
_dir_info_entry_t *entries = get_directory_info(path, &count);
if (!entries) {
term_addf("Could not list %s\n", path);
return;
}
term_addf("Directory listing for %s:\n\n", *path ? path : "(root)");
if (!count) {
term_add_sz("(empty)\n");
return;
}
for (_dir_info_entry_t *i = entries; i < entries + count; ++i) {
str_trunc_fill(i->name, MAX_NAME_LEN);
if (i->is_dir)
term_addf_no_ww("%s" COLUMN_SEP "directory\n", i->name);
else
term_addf_no_ww("%s" COLUMN_SEP "%u bytes\n", i->name, i->size);
}
}
|