mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
du: Add an option to print the human readable sizes in powers of 10
This commit is contained in:
parent
ae36a80a6c
commit
b1c7575769
1 changed files with 4 additions and 0 deletions
|
@ -26,6 +26,7 @@ struct DuOption {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool human_readable = false;
|
bool human_readable = false;
|
||||||
|
bool human_readable_si = false;
|
||||||
bool all = false;
|
bool all = false;
|
||||||
bool apparent_size = false;
|
bool apparent_size = false;
|
||||||
i64 threshold = 0;
|
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.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.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, "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(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(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");
|
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) {
|
if (du_option.human_readable) {
|
||||||
out("{}", human_readable_size(size));
|
out("{}", human_readable_size(size));
|
||||||
|
} else if (du_option.human_readable_si) {
|
||||||
|
out("{}", human_readable_size(size, AK::HumanReadableBasedOn::Base10));
|
||||||
} else {
|
} else {
|
||||||
out("{}", ceil_div(size, du_option.block_size));
|
out("{}", ceil_div(size, du_option.block_size));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue