AK: Add longer human readable size to string helper function
Wraps the existing AK::human_readable_size function but will always display the bytes in the base unit as well as the shorter string with one decimal. E.g. "14 KiB (14396 bytes)".
This commit is contained in:
parent
d3630a7b1f
commit
17c0349d23
Notes:
sideshowbarker
2024-07-18 21:06:20 +09:00
Author: https://github.com/Granddave Commit: https://github.com/SerenityOS/serenity/commit/17c0349d239 Pull-request: https://github.com/SerenityOS/serenity/pull/5937
1 changed files with 9 additions and 0 deletions
|
@ -54,6 +54,15 @@ static inline String human_readable_size(u64 size)
|
|||
return number_string_with_one_decimal(size, EiB, "EiB");
|
||||
}
|
||||
|
||||
static inline String human_readable_size_long(u64 size)
|
||||
{
|
||||
if (size < 1 * KiB)
|
||||
return String::formatted("{} bytes", size);
|
||||
else
|
||||
return String::formatted("{} ({} bytes)", human_readable_size(size), size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using AK::human_readable_size;
|
||||
using AK::human_readable_size_long;
|
||||
|
|
Loading…
Add table
Reference in a new issue