From: Ryan Lortie Date: Mon, 16 Feb 2009 14:22:43 +0000 (+0000) Subject: Bug 505042 – add file attribute for actually used file size in bytes X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=e8c635841a74b58fd73f9a55d8116ebddb7e74e0;p=dana%2Fcg-glib.git Bug 505042 – add file attribute for actually used file size in bytes 2009-02-13 Ryan Lortie Bug 505042 – add file attribute for actually used file size in bytes * gfileinfo.h: add G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE define to "standard::allocated-size" * gfileattribute.c: document * glocalfileinfo.c: set the allocated size from st_blocks * 512 svn path=/trunk/; revision=7865 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index f49c4b65..c27397ea 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,12 @@ +2009-02-13 Ryan Lortie + + Bug 505042 – add file attribute for actually used file size in bytes + + * gfileinfo.h: add G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE define to + "standard::allocated-size" + * gfileattribute.c: document + * glocalfileinfo.c: set the allocated size from st_blocks * 512 + 2009-02-16 Ryan Lortie Bug 571598 – GAsyncResult with NULL gobject diff --git a/gio/gfileattribute.c b/gio/gfileattribute.c index a3bc0ae0..59c702b2 100644 --- a/gio/gfileattribute.c +++ b/gio/gfileattribute.c @@ -148,6 +148,7 @@ * %G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPEstandard::content-typestring * %G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPEstandard::fast-content-typestring * %G_FILE_ATTRIBUTE_STANDARD_SIZEstandard::sizeuint64 + * %G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZEstandard::allocated-sizeuint64 * %G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGETstandard::symlink-targetbyte string * %G_FILE_ATTRIBUTE_STANDARD_TARGET_URIstandard::target-uristring * %G_FILE_ATTRIBUTE_STANDARD_SORT_ORDERstandard::sort-orderint32 diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h index a1499cdf..27eccaa7 100644 --- a/gio/gfileinfo.h +++ b/gio/gfileinfo.h @@ -191,6 +191,18 @@ typedef struct _GFileInfoClass GFileInfoClass; **/ #define G_FILE_ATTRIBUTE_STANDARD_SIZE "standard::size" /* uint64 */ +/** + * G_FILE_ATTRIBUTE_ALLOCATED_SIZE: + * + * A key in the "standard" namespace for getting the amount of disk space + * that is consumed by the file (in bytes). This will generally be larger + * than the file size (due to block size overhead) but can occasionally be + * smaller (for example, for sparse files). + * + * Corresponding #GFileAttributeType is %G_FILE_ATTRIBUTE_TYPE_UINT64. + **/ +#define G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE "standard::allocated-size" /* uint64 */ + /** * G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET: * diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 9aa73319..738a015a 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -940,6 +940,8 @@ set_info_from_stat (GFileInfo *info, #endif #if defined (HAVE_STRUCT_STAT_ST_BLOCKS) g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_BLOCKS, statbuf->st_blocks); + g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE, + statbuf->st_blocks * G_GUINT64_CONSTANT (512)); #endif g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED, statbuf->st_mtime);