| 56 | } |
| 57 | |
| 58 | static size_t parse_size(const char* s) { |
| 59 | char* end = nullptr; |
| 60 | double val = std::strtod(s, &end); |
| 61 | if (end && (*end == 'K' || *end == 'k')) |
| 62 | val *= 1024; |
| 63 | else if (end && (*end == 'M' || *end == 'm')) |
| 64 | val *= 1024 * 1024; |
| 65 | else if (end && (*end == 'G' || *end == 'g')) |
| 66 | val *= 1024 * 1024 * 1024; |
| 67 | return static_cast<size_t>(val); |
| 68 | } |
| 69 | |
| 70 | static std::string fmt_bytes(size_t bytes) { |
| 71 | const char* units[] = {"B", "KB", "MB", "GB", "TB"}; |