[librsvg: 4/11] PathOrUrl: new get_gfile method
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/11] PathOrUrl: new get_gfile method
- Date: Wed, 3 Feb 2021 00:47:24 +0000 (UTC)
commit c3a3ae67bc15679a1099a9f2034dd8b7ae08354f
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 f5efa2b9..674f6030 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -1664,9 +1664,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));
@@ -2178,6 +2176,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]