diff options
author | Bert <ber.t@gmx.com> | 2011-02-03 14:32:02 +0100 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-02-03 14:32:02 +0100 |
commit | bad9a70a48ff38f0d1e22fdedfcaa2241882a0bf (patch) | |
tree | 863ed44c8a15c634da65ae48d1c35767e3afd09c /util.c | |
parent | 12a94cc40ef0f155a9c99dea915cd3807d760441 (diff) |
Display filesize in window title
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -66,3 +66,12 @@ void die(const char* fmt, ...) { cleanup(); exit(1); } + +void size_readable(float *size, const char **unit) { + const char *units[] = { "", "K", "M", "G" }; + int i; + + for (i = 0; i < LEN(units) && *size > 1024; ++i) + *size /= 1024; + *unit = units[MIN(i, LEN(units) - 1)]; +} |