Formats the given number in bytes/kB/MB/GB
| 7 | |
| 8 | // Formats the given number in bytes/kB/MB/GB |
| 9 | inline std::string getFormattedByteSize(std::size_t size) |
| 10 | { |
| 11 | if (size > 1024 * 1024 * 1024) |
| 12 | { |
| 13 | return fmt::format("{0:0.2f} GB", (static_cast<double>(size) / (1024 * 1024 * 1024))); |
| 14 | } |
| 15 | else if (size > 1024 * 1024) |
| 16 | { |
| 17 | return fmt::format("{0:0.1f} MB", (static_cast<double>(size) / (1024 * 1024))); |
| 18 | } |
| 19 | else if (size > 1024) |
| 20 | { |
| 21 | return fmt::format("{0:0.0f} kB", (static_cast<double>(size) / 1024)); |
| 22 | } |
| 23 | else |
| 24 | { |
| 25 | return fmt::format("{0:d} bytes", size); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | } |
no test coverage detected