diff src/util.c @ 5826:bd0d0e89cac3

[gaim-migrate @ 6256] You can once again set your buddy icon. Of course, you* haven't been using CVS, so you've always been able to set your buddy icon. * Gaim developers not applicable committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 10 Jun 2003 01:09:26 +0000
parents dae79aefac8d
children 059d95c67cda
line wrap: on
line diff
--- a/src/util.c	Mon Jun 09 20:34:58 2003 +0000
+++ b/src/util.c	Tue Jun 10 01:09:26 2003 +0000
@@ -1205,3 +1205,27 @@
 
 	return ret;
 }
+
+char *gaim_get_size_string(size_t size)
+{
+	static const char *size_str[4] = { "bytes", "KB", "MB", "GB" };
+	float size_mag;
+	int size_index = 0;
+
+	if (size == -1) {
+		return g_strdup(_("Calculating..."));
+	}
+	else if (size == 0) {
+		return g_strdup(_("Unknown."));
+	}
+	else {
+		size_mag = (float)size;
+
+		while ((size_index < 4) && (size_mag > 1024)) {
+			size_mag /= 1024;
+			size_index++;
+		}
+
+		return g_strdup_printf("%.2f %s", size_mag, size_str[size_index]);
+	}
+}