[librsvg: 8/18] rsvg_get_input_stream_for_loading(): Extract into its own separate function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/18] rsvg_get_input_stream_for_loading(): Extract into its own separate function
- Date: Fri, 23 Nov 2018 22:32:09 +0000 (UTC)
commit e5ada1fedc726119f1428fbe7337c79bd6f73e8a
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Nov 23 09:59:45 2018 -0600
rsvg_get_input_stream_for_loading(): Extract into its own separate function
librsvg/rsvg-load.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index 93d78256..27b9fe30 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -641,16 +641,13 @@ close_impl (RsvgLoad *load, GError ** error)
#define GZ_MAGIC_0 ((guchar) 0x1f)
#define GZ_MAGIC_1 ((guchar) 0x8b)
-gboolean
-rsvg_load_read_stream_sync (RsvgLoad *load,
- GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
+static GInputStream *
+rsvg_get_input_stream_for_loading (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
{
- GError *err = NULL;
- gboolean res = FALSE;
- const guchar *buf;
gssize num_read;
+ const guchar *buf;
/* detect zipped streams */
stream = g_buffered_input_stream_new (stream);
@@ -664,8 +661,7 @@ rsvg_load_read_stream_sync (RsvgLoad *load,
_("Input file is too short"));
}
- load->state = LOAD_STATE_CLOSED;
- return res;
+ return NULL;
}
buf = g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (stream), NULL);
@@ -681,6 +677,24 @@ rsvg_load_read_stream_sync (RsvgLoad *load,
stream = conv_stream;
}
+ return stream;
+}
+
+gboolean
+rsvg_load_read_stream_sync (RsvgLoad *load,
+ GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GError *err = NULL;
+ gboolean res = FALSE;
+
+ stream = rsvg_get_input_stream_for_loading (stream, cancellable, error);
+ if (stream == NULL) {
+ load->state = LOAD_STATE_CLOSED;
+ return FALSE;
+ }
+
load->error = &err;
load->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]