[PATCH] Display binary prefix filesizes instead of decimal prefix filesizes (344296)
- From: Raphael Bosshard <bosshrap zhwin ch>
- To: gnome-vfs-list gnome org
- Subject: [PATCH] Display binary prefix filesizes instead of decimal prefix filesizes (344296)
- Date: Tue, 13 Jun 2006 16:40:36 +0200
See http://bugzilla.gnome.org/show_bug.cgi?id=344296
This patch changes the human readable filesizes
(gnome_vfs_format_file_size_for_display) which are curently displayed
(rather missleading) with binary prefix multipliers (such as Kilo, Mega,
Giga) to more appropriate binary prefix multipiers (Kibi, Mebi, Gibi).
The IEC approved standard symbols (KiB, MiB, GiB) are used.
For more information please read http://en.wikipedia.org/wiki/Binary_prefix
So long,
Raphael
--- gnome-vfs-2.14.2/libgnomevfs/gnome-vfs-utils.c 2006-03-03 10:28:21.000000000 +0100
+++ gnome-vfs-2.14.2-work/libgnomevfs/gnome-vfs-utils.c 2006-06-10 23:03:40.983116272 +0200
@@ -51,9 +51,9 @@
#include <sys/types.h>
#include <unistd.h>
-#define KILOBYTE_FACTOR 1024.0
-#define MEGABYTE_FACTOR (1024.0 * 1024.0)
-#define GIGABYTE_FACTOR (1024.0 * 1024.0 * 1024.0)
+#define KIBIBYTE_FACTOR 1024.0
+#define MEBIBYTE_FACTOR (1024.0 * 1024.0)
+#define GIBIBYTE_FACTORFACTOR (1024.0 * 1024.0 * 1024.0)
#define READ_CHUNK_SIZE 8192
@@ -74,22 +74,22 @@
gchar*
gnome_vfs_format_file_size_for_display (GnomeVFSFileSize size)
{
- if (size < (GnomeVFSFileSize) KILOBYTE_FACTOR) {
+ if (size < (GnomeVFSFileSize) KIBIBYTE_FACTOR) {
return g_strdup_printf (dngettext(GETTEXT_PACKAGE, "%u byte", "%u bytes",(guint) size), (guint) size);
} else {
gdouble displayed_size;
- if (size < (GnomeVFSFileSize) MEGABYTE_FACTOR) {
- displayed_size = (gdouble) size / KILOBYTE_FACTOR;
- return g_strdup_printf (_("%.1f KB"),
+ if (size < (GnomeVFSFileSize) MEBIBYTE_FACTOR) {
+ displayed_size = (gdouble) size / KIBIBYTE_FACTOR;
+ return g_strdup_printf (_("%.1f KiB"),
displayed_size);
- } else if (size < (GnomeVFSFileSize) GIGABYTE_FACTOR) {
- displayed_size = (gdouble) size / MEGABYTE_FACTOR;
- return g_strdup_printf (_("%.1f MB"),
+ } else if (size < (GnomeVFSFileSize) GIBIBYTE_FACTORFACTOR) {
+ displayed_size = (gdouble) size / MEBIBYTE_FACTOR;
+ return g_strdup_printf (_("%.1f MiB"),
displayed_size);
} else {
- displayed_size = (gdouble) size / GIGABYTE_FACTOR;
- return g_strdup_printf (_("%.1f GB"),
+ displayed_size = (gdouble) size / GIBIBYTE_FACTORFACTOR;
+ return g_strdup_printf (_("%.1f GiB"),
displayed_size);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]