[evince] libdocument: Add ev_file_copy_metadata()



commit fd2b09adf5171df9351832a663e122cb4caab427
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Wed May 2 19:24:44 2012 +0200

    libdocument: Add ev_file_copy_metadata()
    
    Helper function to call g_file_copy_attributes() with
    G_FILE_COPY_ALL_METADATA for the given uris.

 .../libdocument/libevdocument-sections.txt         |    1 +
 libdocument/ev-file-helpers.c                      |   38 ++++++++++++++++++++
 libdocument/ev-file-helpers.h                      |    3 ++
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/help/reference/libdocument/libevdocument-sections.txt b/help/reference/libdocument/libevdocument-sections.txt
index 59a5941..8a769d8 100644
--- a/help/reference/libdocument/libevdocument-sections.txt
+++ b/help/reference/libdocument/libevdocument-sections.txt
@@ -696,6 +696,7 @@ ev_tmp_filename_unlink
 ev_tmp_file_unlink
 ev_tmp_uri_unlink
 ev_xfer_uri_simple
+ev_file_copy_metadata
 ev_file_get_mime_type
 ev_file_uncompress
 ev_file_compress
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 5662e9e..47a9738 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -426,6 +426,44 @@ ev_xfer_uri_simple (const char *from,
 	return result;
 }
 
+/**
+ * ev_file_copy_metadata:
+ * @from: the source URI
+ * @to: the target URI
+ * @error: a #GError location to store an error, or %NULL
+ *
+ * Performs a g_file_copy_attributes() with %G_FILE_COPY_ALL_METADATA
+ * from @from to @to.
+ *
+ * Returns: %TRUE if the attributes were copied successfully, %FALSE otherwise.
+ *
+ * Since: 3.4
+ */
+gboolean
+ev_file_copy_metadata (const char *from,
+                       const char *to,
+                       GError     **error)
+{
+        GFile *source_file;
+        GFile *target_file;
+        gboolean result;
+
+        g_return_val_if_fail (from != NULL, FALSE);
+        g_return_val_if_fail (to != NULL, FALSE);
+
+        source_file = g_file_new_for_uri (from);
+        target_file = g_file_new_for_uri (to);
+
+        result = g_file_copy_attributes (source_file, target_file,
+                                         G_FILE_COPY_ALL_METADATA,
+                                         NULL, error);
+
+        g_object_unref (target_file);
+        g_object_unref (source_file);
+
+        return result;
+}
+
 static gchar *
 get_mime_type_from_uri (const gchar *uri, GError **error)
 {
diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h
index e99f30a..ba0d1f9 100644
--- a/libdocument/ev-file-helpers.h
+++ b/libdocument/ev-file-helpers.h
@@ -54,6 +54,9 @@ gboolean     ev_file_is_temp          (GFile             *file);
 gboolean     ev_xfer_uri_simple       (const char        *from,
 				       const char        *to,
 				       GError           **error);
+gboolean     ev_file_copy_metadata    (const char        *from,
+                                       const char        *to,
+                                       GError           **error);
 
 gchar       *ev_file_get_mime_type    (const gchar       *uri,
 				       gboolean           fast,



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