[gcab: 3/6] gcab-file: add gcab_file_get_date_time()
- From: Marc-André Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab: 3/6] gcab-file: add gcab_file_get_date_time()
- Date: Wed, 11 Dec 2019 13:42:54 +0000 (UTC)
commit 776b8c8879d41dd9afe2ba80f7b27fbe0a50d2d7
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Nov 27 12:09:56 2019 +0400
gcab-file: add gcab_file_get_date_time()
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
libgcab/gcab-file.c | 40 +++++++++++++++++++++++++++++++---------
libgcab/gcab-file.h | 2 ++
libgcab/libgcab.syms | 4 ++++
3 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/libgcab/gcab-file.c b/libgcab/gcab-file.c
index 0ff8e0f..1698d12 100644
--- a/libgcab/gcab-file.c
+++ b/libgcab/gcab-file.c
@@ -282,6 +282,35 @@ gcab_file_get_size (GCabFile *self)
return self->cfile->usize;
}
+/**
+ * gcab_file_get_date_time:
+ * @file: a #GCabFile
+ *
+ * Gets the file date and returns it as a #GDateTime..
+ *
+ * Since: 1.4
+ *
+ * Returns: file date, or NULL if unknown.
+ **/
+GDateTime *
+gcab_file_get_date_time (GCabFile *self)
+{
+ guint16 date, time;
+ g_autoptr(GDateTime) dt = NULL;
+
+ g_return_val_if_fail (GCAB_IS_FILE (self), NULL);
+
+ date = self->cfile->date;
+ time = self->cfile->time;
+ dt = g_date_time_new_utc ((date >> 9) + 1980,
+ (date >> 5) & 0xf,
+ (date & 0x1f),
+ (time >> 11),
+ (time >> 5) & 0x3f,
+ (time & 0x1f) * 2);
+ return g_steal_pointer (&dt);
+}
+
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* gcab_file_get_date:
@@ -297,22 +326,15 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gboolean
gcab_file_get_date (GCabFile *self, GTimeVal *tv)
{
- guint16 date, time;
g_autoptr(GDateTime) dt = NULL;
g_return_val_if_fail (GCAB_IS_FILE (self), FALSE);
g_return_val_if_fail (tv != NULL, FALSE);
- date = self->cfile->date;
- time = self->cfile->time;
- dt = g_date_time_new_utc ((date >> 9) + 1980,
- (date >> 5) & 0xf,
- (date & 0x1f),
- (time >> 11),
- (time >> 5) & 0x3f,
- (time & 0x1f) * 2);
+ dt = gcab_file_get_date_time (self);
if (dt == NULL)
return FALSE;
+
return g_date_time_to_timeval (dt, tv);
}
G_GNUC_END_IGNORE_DEPRECATIONS
diff --git a/libgcab/gcab-file.h b/libgcab/gcab-file.h
index 0b72c9b..2ca1c74 100644
--- a/libgcab/gcab-file.h
+++ b/libgcab/gcab-file.h
@@ -75,8 +75,10 @@ guint32 gcab_file_get_attributes (GCabFile *file);
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);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+G_DEPRECATED_FOR(gcab_file_get_date_time)
gboolean gcab_file_get_date (GCabFile *file, GTimeVal *result);
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 c0ad194..19b107f 100644
--- a/libgcab/libgcab.syms
+++ b/libgcab/libgcab.syms
@@ -51,3 +51,7 @@ LIBGCAB1_1.0 {
gcab_folder_get_comptype;
gcab_folder_get_file_by_name;
} LIBGCAB1_0.6;
+
+LIBGCAB1_1.4 {
+ gcab_file_get_date_time;
+} LIBGCAB1_1.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]