[librsvg/rustify-rsvg-convert] PathOrUrl: new get_gfile method



commit c2541401a867520670c1fa92d60c7be6cf3d0dcf
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jan 21 13:46:21 2021 -0600

    PathOrUrl: new get_gfile method

 src/c_api/handle.rs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index 2d706665..5e6208f5 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -1652,9 +1652,7 @@ pub unsafe extern "C" fn rsvg_handle_new_from_file(
     }
 
     let file = match PathOrUrl::new(filename) {
-        Ok(PathOrUrl::Path(path)) => gio::File::new_for_path(path),
-
-        Ok(PathOrUrl::Url(url)) => gio::File::new_for_uri(url.as_str()),
+        Ok(p) => p.get_gfile(),
 
         Err(e) => {
             set_gerror(error, 0, &format!("{}", e));
@@ -2166,6 +2164,13 @@ impl PathOrUrl {
             .and_then(Self::try_from_str)
             .unwrap_or_else(|_| PathOrUrl::Path(PathBuf::from(osstr.to_os_string())))
     }
+
+    pub fn get_gfile(&self) -> gio::File {
+        match *self {
+            PathOrUrl::Path(ref p) => gio::File::new_for_path(p),
+            PathOrUrl::Url(ref u) => gio::File::new_for_uri(u.as_str()),
+        }
+    }
 }
 
 fn check_cairo_context(cr: &cairo::Context) -> Result<(), RenderingError> {


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