Created
September 30, 2012 04:12
-
-
Save alejandrobernardis/3805818 to your computer and use it in GitHub Desktop.
Tree Command, in mac os x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # L: 1107 | |
| # } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9ld", size); | |
| # } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9lld", size); | |
| int psize(char *buf, off_t size) | |
| { | |
| static char *iec_unit="BKMGTPEZY", *si_unit = "dkMGTPEZY"; | |
| char *unit = siflag ? si_unit : iec_unit; | |
| int idx, usize = siflag ? 1000 : 1024; | |
| if (hflag || siflag) { | |
| for (idx=size<usize?0:1; size >= (usize*usize); idx++,size/=usize); | |
| if (!idx) return sprintf(buf, " %4d", (int)size); | |
| else return sprintf(buf, ((size/usize) >= 10)? " %3.0f%c" : " %3.1f%c" , (float)size/(float)usize,unit[idx]); | |
| } else return sprintf(buf, sizeof(off_t) == sizeof(long long)? " %11lld" : " %9lld", size); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment