fixed
This commit is contained in:
parent
1b9dc6d7dc
commit
0737916f1a
11 changed files with 71 additions and 35 deletions
|
@ -2,22 +2,23 @@
|
|||
|
||||
char mu_hs_buf[MU_HUMAN_BUF_SIZE + 1];
|
||||
|
||||
char *mu_humansize(off_t n, off_t block) {
|
||||
char *mu_humansize(off_t n, int block) {
|
||||
memset(mu_hs_buf, '\0', sizeof(mu_hs_buf));
|
||||
|
||||
char *postfixes = "BKMGTPE";
|
||||
|
||||
size_t i = 0;
|
||||
double size = n;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < strlen(postfixes) && size >= block; i++)
|
||||
size /= block;
|
||||
while (size > (off_t)block) {
|
||||
size /= (off_t)block;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i)
|
||||
snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%.1f%c", size, postfixes[i]);
|
||||
|
||||
else
|
||||
snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%ju", n);
|
||||
snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%jd", n);
|
||||
|
||||
return mu_hs_buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue