mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 21:37:58 +03:00
ls: Add an option to print the human readable sizes in powers of 10
This commit is contained in:
parent
b1c7575769
commit
c1ee919add
Notes:
sideshowbarker
2024-07-17 08:13:43 +09:00
Author: https://github.com/kuzux Commit: https://github.com/SerenityOS/serenity/commit/c1ee919add Pull-request: https://github.com/SerenityOS/serenity/pull/16944 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/supercomputer7 ✅
@ -60,6 +60,7 @@ static bool flag_show_inode = false;
|
||||
static bool flag_print_numeric = false;
|
||||
static bool flag_hide_group = false;
|
||||
static bool flag_human_readable = false;
|
||||
static bool flag_human_readable_si = false;
|
||||
static bool flag_sort_by_timestamp = false;
|
||||
static bool flag_reverse_sort = false;
|
||||
static bool flag_disable_hyperlinks = false;
|
||||
@ -113,6 +114,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_option(flag_print_numeric, "In long format, display numeric UID/GID", "numeric-uid-gid", 'n');
|
||||
args_parser.add_option(flag_hide_group, "In long format, do not show group information", nullptr, 'o');
|
||||
args_parser.add_option(flag_human_readable, "Print human-readable sizes", "human-readable", 'h');
|
||||
args_parser.add_option(flag_human_readable_si, "Print human-readable sizes in SI units", "si", 0);
|
||||
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
|
||||
args_parser.add_option(flag_recursive, "List subdirectories recursively", "recursive", 'R');
|
||||
args_parser.add_option(flag_force_newline, "List one file per line", nullptr, '1');
|
||||
@ -357,6 +359,8 @@ static bool print_filesystem_object(DeprecatedString const& path, DeprecatedStri
|
||||
} else {
|
||||
if (flag_human_readable) {
|
||||
printf(" %10s ", human_readable_size(st.st_size).characters());
|
||||
} else if (flag_human_readable_si) {
|
||||
printf(" %10s ", human_readable_size(st.st_size, AK::HumanReadableBasedOn::Base10).characters());
|
||||
} else {
|
||||
printf(" %10" PRIu64 " ", (uint64_t)st.st_size);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user