--- a/gplate/variables/gplate-file-variable.c Sat Jun 19 20:28:56 2010 -0500
+++ b/gplate/variables/gplate-file-variable.c Sat Jun 19 21:23:50 2010 -0500
@@ -49,6 +49,39 @@
static GObjectClass *parent_class = NULL;
/******************************************************************************
+ *****************************************************************************/ +gplate_file_variable_humanize_size(off_t size, gint base) { + const gchar suffix[] = { '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' }; + register gint b = base, m = 0, r = 0, s = (int)size; + str = g_string_new(""); + g_string_append_printf(str, "%d", s); + g_string_append_printf(str, ".%d", r); + g_string_append_c(str, suffix[m]); + g_string_free(str, FALSE); +/****************************************************************************** *****************************************************************************/
@@ -75,6 +108,7 @@
GPlateCollection *collection = NULL;
GPlateVariable *filename_var = NULL;
const gchar *filename = NULL, *type = NULL;
collection = GPLATE_COLLECTION(file_variable);
@@ -128,6 +162,16 @@
gplate_collection_add_string(collection, "type", type);
+ /* figure out the base 1000 size */ + size = gplate_file_variable_humanize_size(st.st_size, 1000); + gplate_collection_add_string(collection, "size1000", size); + /* figure out the base 1024 size */ + size = gplate_file_variable_humanize_size(st.st_size, 1024); + gplate_collection_add_string(collection, "size1024", size); /******************************************************************************