aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-03 14:32:02 +0100
committerBert <ber.t@gmx.com>2011-02-03 14:32:02 +0100
commitbad9a70a48ff38f0d1e22fdedfcaa2241882a0bf (patch)
tree863ed44c8a15c634da65ae48d1c35767e3afd09c /util.c
parent12a94cc40ef0f155a9c99dea915cd3807d760441 (diff)
downloadnsxiv-bad9a70a48ff38f0d1e22fdedfcaa2241882a0bf.tar.zst
Display filesize in window title
Diffstat (limited to 'util.c')
-rw-r--r--util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.c b/util.c
index c357a48..ac81190 100644
--- a/util.c
+++ b/util.c
@@ -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)];
+}