Display filesize in window title

This commit is contained in:
Bert
2011-02-03 14:32:02 +01:00
parent 12a94cc40e
commit bad9a70a48
5 changed files with 75 additions and 39 deletions

9
util.c
View File

@ -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)];
}