[ostree] upgrader: Add ostree_sysroot_upgrader_dup_origin()



commit 41ab26356c082e110c20e8e1601216584a46004b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Oct 6 11:24:23 2015 -0400

    upgrader: Add ostree_sysroot_upgrader_dup_origin()
    
    Convenience function returns a copy of the origin file, useful when
    modifying it.

 doc/ostree-sections.txt                 |    1 +
 src/libostree/ostree-sysroot-upgrader.c |   27 +++++++++++++++++++++++++++
 src/libostree/ostree-sysroot-upgrader.h |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/doc/ostree-sections.txt b/doc/ostree-sections.txt
index 84ba417..ff512e4 100644
--- a/doc/ostree-sections.txt
+++ b/doc/ostree-sections.txt
@@ -410,6 +410,7 @@ ostree_sysroot_upgrader_new_for_os
 OstreeSysrootUpgraderFlags
 ostree_sysroot_upgrader_new_for_os_with_flags
 ostree_sysroot_upgrader_get_origin
+ostree_sysroot_upgrader_dup_origin
 ostree_sysroot_upgrader_set_origin
 ostree_sysroot_upgrader_get_origin_description
 ostree_sysroot_upgrader_check_timestamps
diff --git a/src/libostree/ostree-sysroot-upgrader.c b/src/libostree/ostree-sysroot-upgrader.c
index 3012d31..7ee19f6 100644
--- a/src/libostree/ostree-sysroot-upgrader.c
+++ b/src/libostree/ostree-sysroot-upgrader.c
@@ -342,6 +342,33 @@ ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self)
 }
 
 /**
+ * ostree_sysroot_upgrader_dup_origin:
+ * @self: Sysroot
+ *
+ * Returns: (transfer full): A copy of the origin file, or %NULL if unknown
+ */
+GKeyFile *
+ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self)
+{
+  GKeyFile *copy = NULL;
+
+  g_return_val_if_fail (OSTREE_IS_SYSROOT_UPGRADER (self), NULL);
+
+  if (self->origin != NULL)
+    {
+      g_autofree char *data = NULL;
+      gsize length = 0;
+
+      copy = g_key_file_new ();
+      data = g_key_file_to_data (self->origin, &length, NULL);
+      g_key_file_load_from_data (copy, data, length,
+                                 G_KEY_FILE_KEEP_COMMENTS, NULL);
+    }
+
+  return copy;
+}
+
+/**
  * ostree_sysroot_upgrader_set_origin:
  * @self: Sysroot
  * @origin: (allow-none): The new origin
diff --git a/src/libostree/ostree-sysroot-upgrader.h b/src/libostree/ostree-sysroot-upgrader.h
index edac5a3..394e31a 100644
--- a/src/libostree/ostree-sysroot-upgrader.h
+++ b/src/libostree/ostree-sysroot-upgrader.h
@@ -62,6 +62,7 @@ OstreeSysrootUpgrader *ostree_sysroot_upgrader_new_for_os_with_flags (OstreeSysr
                                                                       GError                    **error);
 
 GKeyFile *ostree_sysroot_upgrader_get_origin (OstreeSysrootUpgrader *self);
+GKeyFile *ostree_sysroot_upgrader_dup_origin (OstreeSysrootUpgrader *self);
 gboolean ostree_sysroot_upgrader_set_origin (OstreeSysrootUpgrader *self, GKeyFile *origin,
                                              GCancellable *cancellable, GError **error);
 


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