This commit is contained in:
2026-01-02 15:47:33 +01:00
parent 1c7dd10089
commit 9d1b50882b
2 changed files with 22 additions and 25 deletions

View File

@@ -1,7 +1,5 @@
#include <array>
#include <cstdint>
#include <filesystem>
#include <log.hpp>
#include <string>
#include <string_view>
#include <utils.hpp>
@@ -23,21 +21,6 @@ std::string center(std::string str, const uint8_t len) {
return str;
}
/* converts large number in (k)bytes to human-readable numer with suffix and sane decimal */
std::string pBytes(double bytes, const bool isKbytes) {
for (constexpr std::array suffix_list = {'K', 'M', 'G', 'T', 'P', 'E', 'Z'}; const auto& suffix : suffix_list) {
if (suffix == 'K' && isKbytes) continue; // skip first loop if already in Kbytes
bytes /= 1024.0;
if (bytes < 1024) {
if (bytes > 100) return pNum(bytes) + suffix;
if (bytes > 10) return pNum(bytes, 1) + suffix;
return pNum(bytes, 2) + suffix;
}
}
return "++++";
}
/* finds first dir in path and returns it. don't refactor, you don't understand it, its fast enough, and you only use it on init */
std::string getFirstDir(const std::string_view& path) {
for (const auto& entry : std::filesystem::directory_iterator(path))