[gcab: 4/6] gcab-file: add gcab_file_set_date_time()



commit 348b4169bf6e29bd04cf5333eed9d1037ea58b64
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Wed Nov 27 12:15:52 2019 +0400

    gcab-file: add gcab_file_set_date_time()
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 libgcab/gcab-file.c  | 31 +++++++++++++++++++++++++------
 libgcab/gcab-file.h  |  2 ++
 libgcab/libgcab.syms |  1 +
 3 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/libgcab/gcab-file.c b/libgcab/gcab-file.c
index 1698d12..4ab0114 100644
--- a/libgcab/gcab-file.c
+++ b/libgcab/gcab-file.c
@@ -180,6 +180,29 @@ gcab_file_class_init (GCabFileClass *klass)
                             G_PARAM_STATIC_STRINGS));
 }
 
+/**
+ * gcab_file_set_date_time:
+ * @file: a #GCabFile
+ * @dt: a #GDateTime
+ *
+ * Sets the file modification date (instead of the date provided by the GFile)
+ *
+ * Since: 1.4
+ **/
+void
+gcab_file_set_date_time (GCabFile *self, GDateTime *dt)
+{
+    g_return_if_fail (GCAB_IS_FILE (self));
+    g_return_if_fail (dt != NULL);
+
+    self->cfile->date = ((g_date_time_get_year (dt) - 1980 ) << 9 ) +
+        ((g_date_time_get_month (dt)) << 5) +
+        (g_date_time_get_day_of_month (dt));
+    self->cfile->time = ((g_date_time_get_hour (dt)) << 11) +
+        (g_date_time_get_minute (dt) << 5) +
+        (g_date_time_get_second (dt) / 2);
+}
+
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 /**
  * gcab_file_set_date:
@@ -194,12 +217,8 @@ void
 gcab_file_set_date (GCabFile *self, const GTimeVal *tv)
 {
     g_autoptr(GDateTime) dt = g_date_time_new_from_timeval_utc (tv);
-    self->cfile->date = ((g_date_time_get_year (dt) - 1980 ) << 9 ) +
-        ((g_date_time_get_month (dt)) << 5) +
-         (g_date_time_get_day_of_month (dt));
-    self->cfile->time = ((g_date_time_get_hour (dt)) << 11) +
-        (g_date_time_get_minute (dt) << 5) +
-        (g_date_time_get_second (dt) / 2);
+
+    gcab_file_set_date_time (self, dt);
 }
 G_GNUC_END_IGNORE_DEPRECATIONS
 
diff --git a/libgcab/gcab-file.h b/libgcab/gcab-file.h
index 2ca1c74..e051a9f 100644
--- a/libgcab/gcab-file.h
+++ b/libgcab/gcab-file.h
@@ -76,10 +76,12 @@ const gchar *   gcab_file_get_extract_name          (GCabFile *file);
 void            gcab_file_set_extract_name          (GCabFile *file, const gchar *name);
 void            gcab_file_set_attributes            (GCabFile *file, guint32 attr);
 GDateTime *     gcab_file_get_date_time             (GCabFile *file);
+void            gcab_file_set_date_time             (GCabFile *file, GDateTime *dt);
 
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 G_DEPRECATED_FOR(gcab_file_get_date_time)
 gboolean        gcab_file_get_date                  (GCabFile *file, GTimeVal *result);
+G_DEPRECATED_FOR(gcab_file_set_date_time)
 void            gcab_file_set_date                  (GCabFile *file, const GTimeVal *tv);
 G_GNUC_END_IGNORE_DEPRECATIONS
 
diff --git a/libgcab/libgcab.syms b/libgcab/libgcab.syms
index 19b107f..9d96c74 100644
--- a/libgcab/libgcab.syms
+++ b/libgcab/libgcab.syms
@@ -54,4 +54,5 @@ LIBGCAB1_1.0 {
 
 LIBGCAB1_1.4 {
         gcab_file_get_date_time;
+        gcab_file_set_date_time;
 } LIBGCAB1_1.0;


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