From 79973061600a2af480c4f8ec1e1e71846985b653 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 17 Feb 2021 17:59:05 -0500 Subject: dirlist program, making fat refuse to list file as directory --- src/user/knob/block.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/user/knob/block.c') diff --git a/src/user/knob/block.c b/src/user/knob/block.c index 90f79e3..1720f94 100644 --- a/src/user/knob/block.c +++ b/src/user/knob/block.c @@ -57,4 +57,20 @@ uint32_t strlen(const char *str) { ++str; } return len; +} + +void str_trunc_fill(char *str, uint32_t len) { + const uint8_t orig_len = strlen(str); + if (orig_len > len) { + str[len - 4] = ' '; + str[len - 3] = '.'; + str[len - 2] = '.'; + str[len - 1] = '.'; + str[len] = '\0'; + } + else if (orig_len != len) { + for (uint8_t j = orig_len; j < len; ++j) + str[j] = ' '; + str[len] = '\0'; + } } \ No newline at end of file -- cgit v1.2.3