rename funcs, move get_val

This commit is contained in:
2025-12-14 14:45:06 +01:00
parent cd94018426
commit a271711441
5 changed files with 28 additions and 29 deletions

View File

@@ -7,8 +7,8 @@
#define FILL_CHAR ' '
// wrapper around readFile2 func so we can avoid readFile and reuse one buffer, this should be faster and less bug prone?
#define fastReadNum(path, val) readFile2(path, buf, sizeof(buf)); val = strtoll(buf, NULL, 10)
// wrapper around readFile func so we can avoid readFileToStr and reuse one buffer, this should be faster and less bug prone?
#define fastReadNum(path, val) readFile(path, buf, sizeof(buf)); val = strtoll(buf, NULL, 10)
enum JUST {
RIGHT,
@@ -21,10 +21,9 @@ inline std::string pNum(auto num, uint8_t decs = 0) { return std::format("{:.{}f
std::string pad(std::string s, uint8_t len, JUST j = JUST::RIGHT);
std::string center(std::string str, uint8_t len);
std::string pBytes(double bytes, bool isKbytes = false);
std::string readFile(std::string path, size_t trim = 4096);
ssize_t readFile2(std::string path, char* buffer, size_t maxlen);
ssize_t readFile2(const char* path, char* buffer, size_t maxlen);
int get_val(std::string_view target, std::string_view content);
std::string readFileToStr(std::string path, size_t trim = 4096);
ssize_t readFile(std::string path, char* buffer, size_t maxlen);
ssize_t readFile(const char* path, char* buffer, size_t maxlen);
std::string getFirstDir(std::string_view path);
#endif