Mercurial > hg > toybox
comparison lib/pending.c @ 1011:6cb9e7142574
Remove files du no longer needs.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 18 Aug 2013 04:12:51 -0500 |
parents | 893c86bbe452 |
children | f8824260d057 |
comparison
equal
deleted
inserted
replaced
1010:b3c89d37143b | 1011:6cb9e7142574 |
---|---|
32 if (!strcmp(basename(cmd), *curname)) | 32 if (!strcmp(basename(cmd), *curname)) |
33 if (!callback(atol(entry->d_name), *curname)) goto done; | 33 if (!callback(atol(entry->d_name), *curname)) goto done; |
34 } | 34 } |
35 done: | 35 done: |
36 closedir(dp); | 36 closedir(dp); |
37 } | |
38 | |
39 char* make_human_readable(unsigned long long size, unsigned long unit) | |
40 { | |
41 unsigned int frac = 0; | |
42 if(unit) { | |
43 size = (size/(unit)) + (size%(unit)?1:0); | |
44 return xmsprintf("%llu", size); | |
45 } | |
46 else { | |
47 static char units[] = {'\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}; | |
48 int index = 0; | |
49 while(size >= 1024) { | |
50 frac = size%1024; | |
51 size /= 1024; | |
52 index++; | |
53 } | |
54 frac = (frac/102) + ((frac%102)?1:0); | |
55 if(frac >= 10) { | |
56 size += 1; | |
57 frac = 0; | |
58 } | |
59 if(frac) return xmsprintf("%llu.%u%c", size, frac, units[index]); | |
60 else return xmsprintf("%llu%c", size, units[index]); | |
61 } | |
62 return NULL; //not reached | |
63 } | 37 } |
64 | 38 |
65 /* | 39 /* |
66 * used to get the interger value. | 40 * used to get the interger value. |
67 */ | 41 */ |