This commit is contained in:
2026-01-02 12:43:45 +01:00
parent c0af0dee95
commit 58f5578de0

View File

@@ -13,13 +13,13 @@
namespace utils {
/* pads given string to length */
std::string pad(std::string s, const uint8_t len, just j) {
std::string pad(std::string s, const uint8_t len, const just j) {
if (len > s.size())
s.insert(j == 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, const uint8_t len) {
const uint8_t padding = len - str.size();
str.insert(str.begin(), padding / 2, fill_char);
@@ -42,7 +42,7 @@ std::string pBytes(double bytes, const bool isKbytes) {
}
/* reads maxlen of chars of the file in path into buffer */
ssize_t readFile(const char* path, char* buffer, size_t maxlen) {
ssize_t readFile(const char* path, char* buffer, const size_t maxlen) {
const int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
applog(LOG::ERR, "Error reading {}", path);
@@ -55,7 +55,7 @@ ssize_t readFile(const char* 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) {
ssize_t readFile(const std::string& path, char* buffer, const size_t maxlen) {
return readFile(path.c_str(), buffer, maxlen);
}