gio: add GBytes-based input/output stream methods

Using a caller-supplied buffer for g_input_stream_read() doesn't
translate well to the semantics of many other languages, and using a
non-refcounted buffer for read_async() and write_async() makes it
impossible to manage the memory correctly currently in
garbage-collected languages.

Fix both of these issues by adding a new set of methods that work with
GBytes objects rather than plain buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=671139
This commit is contained in:
Dan Winship
2012-04-05 09:19:17 -04:00
committed by Jasper St. Pierre
parent 4b456635e4
commit 800d6ff111
8 changed files with 428 additions and 0 deletions

View File

@@ -146,6 +146,11 @@ gboolean g_output_stream_write_all (GOutputStream *stream,
gsize *bytes_written,
GCancellable *cancellable,
GError **error);
GLIB_AVAILABLE_IN_2_34
gssize g_output_stream_write_bytes (GOutputStream *stream,
GBytes *bytes,
GCancellable *cancellable,
GError **error);
gssize g_output_stream_splice (GOutputStream *stream,
GInputStream *source,
GOutputStreamSpliceFlags flags,
@@ -167,6 +172,17 @@ void g_output_stream_write_async (GOutputStream *stream,
gssize g_output_stream_write_finish (GOutputStream *stream,
GAsyncResult *result,
GError **error);
GLIB_AVAILABLE_IN_2_34
void g_output_stream_write_bytes_async (GOutputStream *stream,
GBytes *bytes,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GLIB_AVAILABLE_IN_2_34
gssize g_output_stream_write_bytes_finish (GOutputStream *stream,
GAsyncResult *result,
GError **error);
void g_output_stream_splice_async (GOutputStream *stream,
GInputStream *source,
GOutputStreamSpliceFlags flags,