[libgsf] GsfOutfileMSOle: modtime support.



commit cd4205f1b643adddff6c49406929595950f6b3a6
Author: Morten Welinder <terra gnome org>
Date:   Fri Mar 8 12:04:44 2013 -0500

    GsfOutfileMSOle: modtime support.

 ChangeLog               |    3 +++
 NEWS                    |    1 +
 gsf/gsf-outfile-msole.c |   16 ++++++++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5182b52..32b9b97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-03-08  Morten Welinder  <terra gnome org>
 
+       * gsf/gsf-outfile-msole.c (gsf_outfile_msole_close_root): Set
+       modtime when available.
+
        * gsf/gsf-output.c (gsf_output_set_property): Make name property
        writable.
 
diff --git a/NEWS b/NEWS
index fba5e32..026c192 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Morten:
        * Add modtime support for GsfInput, GsfInputStdio, GsfInputGzip.
        * Add modtime support for GsfInfileZip, GsfInfileTar, GsfInfileMSOle.
        * Add modtime support for GsfOutput, GsfOutputStdio, GsfOutputGzip.
+       * Add modtime support for GsfOutfileZip, GsfOutfileMSOle.
        * Enhance gsf tool to print modtime and create archives with modtime.
 
 --------------------------------------------------------------------------
diff --git a/gsf/gsf-outfile-msole.c b/gsf/gsf-outfile-msole.c
index 16ac719..7f47592 100644
--- a/gsf/gsf-outfile-msole.c
+++ b/gsf/gsf-outfile-msole.c
@@ -279,6 +279,19 @@ ole_write_const (GsfOutput *sink, guint32 value, unsigned n)
 #undef FLUSH
 #undef ADD_ITEM
 
+static guint64
+datetime_to_filetime (GDateTime *dt)
+{
+       static const guint64 epoch = G_GINT64_CONSTANT (11644473600);
+       GTimeVal tv;
+       if (!dt)
+               return 0u;
+
+       /* ft is number of 100ns since Jan 1 1601 */
+       g_date_time_to_timeval (dt, &tv);
+       return (tv.tv_sec + epoch) * 10000000u + tv.tv_usec * 10u;
+}
+
 static void
 ole_pad_bat_unused (GsfOutfileMSOle *ole, unsigned residual)
 {
@@ -386,6 +399,9 @@ gsf_outfile_msole_close_root (GsfOutfileMSOle *ole)
                        GSF_LE_SET_GUINT32 (buf + DIRENT_FIRSTBLOCK, child->first_block);
                        GSF_LE_SET_GUINT32 (buf + DIRENT_FILE_SIZE, size);
                }
+               GSF_LE_SET_GUINT64 (buf + DIRENT_MODIFY_TIME,
+                                   datetime_to_filetime (gsf_output_get_modtime (GSF_OUTPUT (child))));
+
                /* make everything black (red == 0) */
                GSF_LE_SET_GUINT8  (buf + DIRENT_COLOUR, 1);
 


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