15 const char *units[] = {
"B",
"KiB",
"MiB",
"GiB",
"TiB",
"PiB",
"EiB" };
17 double readable_size = (double) size;
19 while (readable_size >= 1024.0 && i < (
sizeof(units) /
sizeof(units[0]) - 1)) {
20 readable_size /= 1024.0;
25 return apr_psprintf(pool,
"%d %s", (
int) readable_size, units[i]);
28 return apr_psprintf(pool,
"%.1f %s", readable_size, units[i]);
35 double size = strtod(size_str, &endptr);
36 apr_off_t multiplier = 1;
38 if (endptr == size_str) {
42 while (*endptr && isspace((
unsigned char) *endptr)) {
47 switch (toupper((
unsigned char) *endptr)) {
49 multiplier = 1024LL * 1024LL * 1024LL * 1024LL;
52 multiplier = 1024LL * 1024LL * 1024LL;
55 multiplier = 1024LL * 1024LL;
65 return (apr_off_t) (size * multiplier);