| 426 | } |
| 427 | |
| 428 | std::string util::format_data_size(size_t size) { |
| 429 | if (size < 1024) { |
| 430 | return std::to_string(size)+" B"; |
| 431 | } |
| 432 | const std::string postfixes[] { |
| 433 | " B", " KiB", " MiB", " GiB", " TiB", " EiB", " PiB" |
| 434 | }; |
| 435 | int group = 0; |
| 436 | size_t remainder = 0; |
| 437 | while (size >= 1024) { |
| 438 | group++; |
| 439 | remainder = size % 1024; |
| 440 | size /= 1024; |
| 441 | } |
| 442 | return std::to_string(size)+"."+ |
| 443 | std::to_string(static_cast<int>(round(remainder/1024.0f)))+ |
| 444 | postfixes[group]; |
| 445 | } |
| 446 | |
| 447 | std::pair<std::string, std::string> util::split_at(std::string_view view, char c) { |
| 448 | size_t idx = view.find(c); |
nothing calls this directly
no test coverage detected