f/w fncs
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user