Bug 505042 – add file attribute for actually used file size in bytes
authorRyan Lortie <desrt@desrt.ca>
Mon, 16 Feb 2009 14:22:43 +0000 (14:22 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 16 Feb 2009 14:22:43 +0000 (14:22 +0000)
2009-02-13  Ryan Lortie  <desrt@desrt.ca>

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

gio/ChangeLog
gio/gfileattribute.c
gio/gfileinfo.h
gio/glocalfileinfo.c

index f49c4b6..c27397e 100644 (file)
@@ -1,3 +1,12 @@
+2009-02-13  Ryan Lortie  <desrt@desrt.ca>
+
+       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  <desrt@desrt.ca>
 
        Bug 571598 – GAsyncResult with NULL gobject
index a3bc0ae..59c702b 100644 (file)
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE</entry><entry>standard::content-type</entry><entry>string</entry></row>
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE</entry><entry>standard::fast-content-type</entry><entry>string</entry></row>
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_SIZE</entry><entry>standard::size</entry><entry>uint64</entry></row>
+ * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE</entry><entry>standard::allocated-size</entry><entry>uint64</entry></row>
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET</entry><entry>standard::symlink-target</entry><entry>byte string</entry></row>
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_TARGET_URI</entry><entry>standard::target-uri</entry><entry>string</entry></row>
  * <row><entry>%G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER</entry><entry>standard::sort-order</entry><entry>int32</entry></row>
index a1499cd..27eccaa 100644 (file)
@@ -192,6 +192,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:
  *
  * A key in the "standard" namespace for getting the symlink target, if the file
index 9aa7331..738a015 100644 (file)
@@ -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);