From e6ec18eccfa0dedfdddcf847afb9e0b3b4866223 Mon Sep 17 00:00:00 2001 From: Drath Date: Sun, 14 Dec 2025 15:02:34 +0100 Subject: [PATCH] cleanup --- src/utils.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index ad233d4..fe36113 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -12,14 +11,14 @@ #include #include -// pads given string to length +/* pads given string to length */ std::string pad(std::string s, uint8_t len, JUST j) { if (len > s.size()) s.insert(j == JUST::LEFT ? s.end() : s.begin(), len - s.size(), FILL_CHAR); return s; } -// returns the string centered within given length +/* returns the string centered within given length */ std::string center(std::string str, uint8_t len) { uint8_t padding = len - str.size(); str.insert(str.begin(), padding / 2, FILL_CHAR); @@ -27,7 +26,7 @@ std::string center(std::string str, uint8_t len) { return str; } -// converts large number in (k)bytes to human readable numer with suffix and sane decimal +/* converts large number in (k)bytes to human readable numer with suffix and sane decimal */ std::string pBytes(double bytes, bool isKbytes) { std::array suffix_list = {'K', 'M', 'G', 'T', 'P', 'E', 'Z'}; for (auto& suffix : suffix_list) { @@ -42,7 +41,7 @@ std::string pBytes(double bytes, bool isKbytes) { return "++++"; } -/* SENSOR GETTERS + UTILS*/ +/* reads maxlen of chars of the file in path into buffer */ ssize_t readFile(const char* path, char* buffer, size_t maxlen) { int fd = open(path, O_RDONLY | O_CLOEXEC); if (fd < 0) { @@ -55,7 +54,8 @@ ssize_t readFile(const char* path, char* buffer, size_t maxlen) { return len; } -ssize_t readFile(std::string path, char* buffer, size_t maxlen) { +/* overload so it takes std::string as path */ +ssize_t readFile(const std::string path, char* buffer, size_t maxlen) { return readFile(path.c_str(), buffer, maxlen); }