From 3c8a448a2ff6b433059b1beb3a35cfd67c148d0c Mon Sep 17 00:00:00 2001 From: Jakob Gruber Date: Sun, 20 Feb 2011 19:38:32 +0100 Subject: Add a utility function to humanize sizes Converts the given size in bytes in two possible ways: 1) target_unit is specified (!= 0): size is converted to target unit. 2) target_unit is not specified (== '\0'): size is converted to the first unit which will bring size to below 2048. If specified, label will point to the long label ('MB') if long_labels is set or the short label ('M') if it is not. Dan: use '\0' rather than 0 for the special value as a matter of coding style for char variables. Signed-off-by: Jakob Gruber Signed-off-by: Dan McGee --- src/pacman/util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/pacman/util.h') diff --git a/src/pacman/util.h b/src/pacman/util.h index 234a631d..6a20ba4f 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -52,6 +52,7 @@ char *strtrim(char *str); char *strreplace(const char *str, const char *needle, const char *replace); alpm_list_t *strsplit(const char *str, const char splitchar); void string_display(const char *title, const char *string); +double humanize_size(off_t bytes, const char target_unit, int long_labels, const char **label); void list_display(const char *title, const alpm_list_t *list); void list_display_linebreak(const char *title, const alpm_list_t *list); void display_targets(const alpm_list_t *pkgs, int install); -- cgit v1.2.3-24-g4f1b