[librsvg: 7/11] rsvg_handle_new_from_file(): Use the GFile machinery to convert a filename to a URI



commit 4de19d9fdddf81773125b04a4defe1ffd0d3bfe0
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Dec 4 18:26:39 2017 -0600

    rsvg_handle_new_from_file(): Use the GFile machinery to convert a filename to a URI

 rsvg-base-file-util.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/rsvg-base-file-util.c b/rsvg-base-file-util.c
index d33f93f..c443f08 100644
--- a/rsvg-base-file-util.c
+++ b/rsvg-base-file-util.c
@@ -87,11 +87,22 @@ rsvg_handle_new_from_file (const gchar * file_name, GError ** error)
     char *data;
     gsize data_len;
     RsvgHandle *handle = NULL;
+    GFile *file;
 
     rsvg_return_val_if_fail (file_name != NULL, NULL, error);
 
-    base_uri = rsvg_get_base_uri_from_filename (file_name);
-    data = _rsvg_io_acquire_data (file_name, base_uri, NULL, &data_len, NULL, error);
+    file = g_file_new_for_path (file_name);
+    base_uri = g_file_get_uri (file);
+    if (!base_uri) {
+        g_set_error (error,
+                     G_IO_ERROR,
+                     G_IO_ERROR_FAILED,
+                     _("Cannot obtain URI from '%s'"), file_name);
+        g_object_unref (file);
+        return NULL;
+    }
+
+    data = _rsvg_io_acquire_data (base_uri, base_uri, NULL, &data_len, NULL, error);
 
     if (data) {
         handle = rsvg_handle_new ();


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