[glib] Add TB and PB cases to g_format_size_for_display
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Add TB and PB cases to g_format_size_for_display
- Date: Thu, 26 Nov 2009 09:20:35 +0000 (UTC)
commit b3156508c49f5274805de1d0d9bc5a69f43de1e9
Author: Christian Persch <chpe gnome org>
Date: Sat May 24 21:00:11 2008 +0200
Add TB and PB cases to g_format_size_for_display
glib/gfileutils.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 3633753..76335fa 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1742,9 +1742,12 @@ g_build_filename (const gchar *first_element,
return str;
}
-#define KILOBYTE_FACTOR 1024.0
-#define MEGABYTE_FACTOR (1024.0 * 1024.0)
-#define GIGABYTE_FACTOR (1024.0 * 1024.0 * 1024.0)
+#define KILOBYTE_FACTOR (G_GOFFSET_CONSTANT (1024))
+#define MEGABYTE_FACTOR (KILOBYTE_FACTOR * KILOBYTE_FACTOR)
+#define GIGABYTE_FACTOR (MEGABYTE_FACTOR * KILOBYTE_FACTOR)
+#define TERABYTE_FACTOR (GIGABYTE_FACTOR * KILOBYTE_FACTOR)
+#define PETABYTE_FACTOR (TERABYTE_FACTOR * KILOBYTE_FACTOR)
+#define EXABYTE_FACTOR (PETABYTE_FACTOR * KILOBYTE_FACTOR)
/**
* g_format_size_for_display:
@@ -1775,19 +1778,34 @@ g_format_size_for_display (goffset size)
if (size < (goffset) MEGABYTE_FACTOR)
{
- displayed_size = (gdouble) size / KILOBYTE_FACTOR;
+ displayed_size = (gdouble) size / (gdouble) KILOBYTE_FACTOR;
return g_strdup_printf (_("%.1f KB"), displayed_size);
}
else if (size < (goffset) GIGABYTE_FACTOR)
{
- displayed_size = (gdouble) size / MEGABYTE_FACTOR;
+ displayed_size = (gdouble) size / (gdouble) MEGABYTE_FACTOR;
return g_strdup_printf (_("%.1f MB"), displayed_size);
}
- else
+ else if (size < (goffset) TERABYTE_FACTOR)
{
- displayed_size = (gdouble) size / GIGABYTE_FACTOR;
+ displayed_size = (gdouble) size / (gdouble) GIGABYTE_FACTOR;
return g_strdup_printf (_("%.1f GB"), displayed_size);
}
+ else if (size < (goffset) PETABYTE_FACTOR)
+ {
+ displayed_size = (gdouble) size / (gdouble) TERABYTE_FACTOR;
+ return g_strdup_printf (_("%.1f TB"), displayed_size);
+ }
+ else if (size < (goffset) EXABYTE_FACTOR)
+ {
+ displayed_size = (gdouble) size / (gdouble) PETABYTE_FACTOR;
+ return g_strdup_printf (_("%.1f PB"), displayed_size);
+ }
+ else
+ {
+ displayed_size = (gdouble) size / (gdouble) EXABYTE_FACTOR;
+ return g_strdup_printf (_("%.1f EB"), displayed_size);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]