| 4501 | } |
| 4502 | |
| 4503 | String String::humanize_size(uint64_t p_size) { |
| 4504 | int magnitude = 0; |
| 4505 | uint64_t _div = 1; |
| 4506 | while (p_size > _div * 1024 && magnitude < 6) { |
| 4507 | _div *= 1024; |
| 4508 | magnitude++; |
| 4509 | } |
| 4510 | |
| 4511 | if (magnitude == 0) { |
| 4512 | return String::num_uint64(p_size) + " " + RTR("B"); |
| 4513 | } else { |
| 4514 | String suffix; |
| 4515 | switch (magnitude) { |
| 4516 | case 1: |
| 4517 | suffix = RTR("KiB"); |
| 4518 | break; |
| 4519 | case 2: |
| 4520 | suffix = RTR("MiB"); |
| 4521 | break; |
| 4522 | case 3: |
| 4523 | suffix = RTR("GiB"); |
| 4524 | break; |
| 4525 | case 4: |
| 4526 | suffix = RTR("TiB"); |
| 4527 | break; |
| 4528 | case 5: |
| 4529 | suffix = RTR("PiB"); |
| 4530 | break; |
| 4531 | case 6: |
| 4532 | suffix = RTR("EiB"); |
| 4533 | break; |
| 4534 | } |
| 4535 | |
| 4536 | const double divisor = _div; |
| 4537 | const int digits = _humanize_digits(p_size / _div); |
| 4538 | return String::num(p_size / divisor).pad_decimals(digits) + " " + suffix; |
| 4539 | } |
| 4540 | } |
| 4541 | |
| 4542 | bool String::is_absolute_path() const { |
| 4543 | if (length() > 1) { |
nothing calls this directly
no test coverage detected