[gcab] file: add attributes getters



commit f214d6c92266a53f77eeb6548bdcf164ae0c2b3f
Author: Marc-André Lureau <marcandre lureau gmail com>
Date:   Thu Mar 12 22:36:13 2015 +0100

    file: add attributes getters

 libgcab.syms        |    3 ++
 libgcab/gcab-file.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++
 libgcab/gcab-file.h |    3 ++
 3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/libgcab.syms b/libgcab.syms
index f312c26..d4b5c19 100644
--- a/libgcab.syms
+++ b/libgcab.syms
@@ -37,4 +37,7 @@ LIBGCAB1_0.5 {
 
 LIBGCAB1_0.6 {
         gcab_file_attribute_get_type;
+        gcab_file_get_attributes;
+        gcab_file_get_date;
+        gcab_file_get_size;
 } LIBGCAB1_0.5;
diff --git a/libgcab/gcab-file.c b/libgcab/gcab-file.c
index af77dd1..b55fbb5 100644
--- a/libgcab/gcab-file.c
+++ b/libgcab/gcab-file.c
@@ -159,6 +159,75 @@ gcab_file_set_uoffset (GCabFile *self, u4 uoffset)
 }
 
 /**
+ * gcab_file_get_size:
+ * @file: a #GCabFile
+ *
+ * Get the file size.
+ *
+ * Returns: the cabinet file size
+ * Since: 0.6
+ **/
+guint32
+gcab_file_get_size (GCabFile *self)
+{
+    g_return_val_if_fail (GCAB_IS_FILE (self), 0);
+
+    return self->cfile.usize;
+}
+
+/**
+ * gcab_file_get_date:
+ * @file: a #GCabFile
+ * @result: a #GTimeVal to return date
+ *
+ * Get the file date.
+ *
+ * Returns: the cabinet file date in @result
+ * Since: 0.6
+ **/
+void
+gcab_file_get_date (GCabFile *self, GTimeVal *tv)
+{
+    struct tm tm;
+    guint16 date, time;
+
+    g_return_if_fail (GCAB_IS_FILE (self));
+    g_return_if_fail (tv != NULL);
+
+    date = self->cfile.date;
+    time = self->cfile.time;
+
+    tm.tm_isdst = -1;
+    tm.tm_year  = ((date >> 9) + 1980) - 1900;
+    tm.tm_mon   = ((date >> 5) & 0xf) - 1;
+    tm.tm_mday  = (date & 0x1f) - 1;
+
+    tm.tm_hour  = (time >> 11);
+    tm.tm_min   = ((time >> 5) & 0x3f);
+    tm.tm_sec   = (time & 0x1f) * 2;
+
+    tv->tv_sec  = mktime(&tm);
+    tv->tv_usec = 0;
+}
+
+/**
+ * gcab_file_get_attributes:
+ * @file: a #GCabFile
+ *
+ * Get the file attributes.
+ *
+ * Returns: the cabinet file attributes
+ * Since: 0.6
+ **/
+guint32
+gcab_file_get_attributes (GCabFile *self)
+{
+    g_return_val_if_fail (GCAB_IS_FILE (self), 0);
+
+    return self->cfile.fattr;
+}
+
+/**
  * gcab_file_get_name:
  * @file: a #GCabFile
  *
diff --git a/libgcab/gcab-file.h b/libgcab/gcab-file.h
index a1485a7..354d537 100644
--- a/libgcab/gcab-file.h
+++ b/libgcab/gcab-file.h
@@ -75,6 +75,9 @@ GType gcab_file_get_type (void) G_GNUC_CONST;
 GCabFile *      gcab_file_new_with_file             (const gchar *name, GFile *file);
 GFile *         gcab_file_get_file                  (GCabFile *file);
 const gchar *   gcab_file_get_name                  (GCabFile *file);
+guint32         gcab_file_get_size                  (GCabFile *file);
+guint32         gcab_file_get_attributes            (GCabFile *file);
+void            gcab_file_get_date                  (GCabFile *file, GTimeVal *result);
 const gchar *   gcab_file_get_extract_name          (GCabFile *file);
 void            gcab_file_set_extract_name          (GCabFile *file, const gchar *name);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]