diff options
author | Arda Cinar <kuzux92@gmail.com> | 2023-01-10 15:08:57 +0300 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-01-15 19:12:19 +0100 |
commit | b1c75757694ede6fc4ed8b4cab7bd05bb046d0e5 (patch) | |
tree | ff0dcc30d673d2b235d7f58dee12e212e49a55d4 | |
parent | ae36a80a6c7622ae1d017d619e6fd1b393481d3a (diff) | |
download | serenity-b1c75757694ede6fc4ed8b4cab7bd05bb046d0e5.zip |
du: Add an option to print the human readable sizes in powers of 10
-rw-r--r-- | Userland/Utilities/du.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index d018e79d5a..5de11b6db4 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -26,6 +26,7 @@ struct DuOption { }; bool human_readable = false; + bool human_readable_si = false; bool all = false; bool apparent_size = false; i64 threshold = 0; @@ -97,6 +98,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi args_parser.add_option(du_option.all, "Write counts for all files, not just directories", "all", 'a'); args_parser.add_option(du_option.apparent_size, "Print apparent sizes, rather than disk usage", "apparent-size", 0); args_parser.add_option(du_option.human_readable, "Print human-readable sizes", "human-readable", 'h'); + args_parser.add_option(du_option.human_readable_si, "Print human-readable sizes in SI units", "si", 0); args_parser.add_option(du_option.max_depth, "Print the total for a directory or file only if it is N or fewer levels below the command line argument", "max-depth", 'd', "N"); args_parser.add_option(summarize, "Display only a total for each argument", "summarize", 's'); args_parser.add_option(du_option.threshold, "Exclude entries smaller than size if positive, or entries greater than size if negative", "threshold", 't', "size"); @@ -174,6 +176,8 @@ ErrorOr<u64> print_space_usage(DeprecatedString const& path, DuOption const& du_ if (du_option.human_readable) { out("{}", human_readable_size(size)); + } else if (du_option.human_readable_si) { + out("{}", human_readable_size(size, AK::HumanReadableBasedOn::Base10)); } else { out("{}", ceil_div(size, du_option.block_size)); } |