| 273 | #endif /* _WIN32 */ |
| 274 | |
| 275 | string string_human_readable_size(size_t size) |
| 276 | { |
| 277 | static const char suffixes[] = "BKMGTPEZY"; |
| 278 | |
| 279 | const char *suffix = suffixes; |
| 280 | size_t r = 0; |
| 281 | |
| 282 | while (size >= 1024) { |
| 283 | r = size % 1024; |
| 284 | size /= 1024; |
| 285 | suffix++; |
| 286 | } |
| 287 | |
| 288 | if (*suffix != 'B') { |
| 289 | return string_printf("%.2f%c", double(size * 1024 + r) / 1024.0, *suffix); |
| 290 | } |
| 291 | return string_printf("%zu", size); |
| 292 | } |
| 293 | |
| 294 | string string_human_readable_number(size_t num) |
| 295 | { |
no test coverage detected