{
GBufferedInputStream *bstream;
GBufferedInputStreamPrivate *priv;
+ GBufferedInputStreamClass *class;
GInputStream *base_stream;
gsize available, bytes_skipped;
gssize nread;
return bytes_skipped;
}
- g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
- nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
- g_input_stream_set_pending (stream, TRUE); /* enable again */
+ class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
+ nread = class->fill (bstream, priv->len, cancellable, error);
if (nread < 0)
{
{
GBufferedInputStream *bstream;
GBufferedInputStreamPrivate *priv;
+ GBufferedInputStreamClass *class;
GInputStream *base_stream;
gsize available, bytes_read;
gssize nread;
return bytes_read;
}
- g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
- nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
- g_input_stream_set_pending (stream, TRUE); /* enable again */
+ class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
+ nread = class->fill (bstream, priv->len, cancellable, error);
if (nread < 0)
{
if (bytes_read == 0)
GError **error)
{
GBufferedInputStreamPrivate *priv;
+ GBufferedInputStreamClass *class;
GInputStream *input_stream;
gsize available;
gssize nread;
/* Byte not available, request refill for more */
+ g_input_stream_set_pending (input_stream, TRUE);
+
if (cancellable)
g_push_current_cancellable (cancellable);
priv->pos = 0;
priv->end = 0;
- nread = g_buffered_input_stream_fill (stream, priv->len, cancellable, error);
+ class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
+ nread = class->fill (stream, priv->len, cancellable, error);
if (cancellable)
g_pop_current_cancellable (cancellable);
+ g_input_stream_set_pending (input_stream, FALSE);
+
if (nread <= 0)
return -1; /* error or end of stream */
bstream = G_BUFFERED_INPUT_STREAM (source_object);
priv = bstream->priv;
- g_input_stream_set_pending (G_INPUT_STREAM (bstream), TRUE); /* enable again */
-
data = g_simple_async_result_get_op_res_gpointer (simple);
error = NULL;
{
GBufferedInputStream *bstream;
GBufferedInputStreamPrivate *priv;
+ GBufferedInputStreamClass *class;
GInputStream *base_stream;
gsize available;
GSimpleAsyncResult *simple;
}
else
{
- g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
- g_buffered_input_stream_fill_async (bstream, priv->len,
- io_priority, cancellable,
- read_fill_buffer_callback, simple);
+ class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
+ class->fill_async (bstream, priv->len, io_priority, cancellable,
+ read_fill_buffer_callback, simple);
}
}
bstream = G_BUFFERED_INPUT_STREAM (source_object);
priv = bstream->priv;
- g_input_stream_set_pending (G_INPUT_STREAM (bstream), TRUE); /* enable again */
-
data = g_simple_async_result_get_op_res_gpointer (simple);
error = NULL;
{
GBufferedInputStream *bstream;
GBufferedInputStreamPrivate *priv;
+ GBufferedInputStreamClass *class;
GInputStream *base_stream;
gsize available;
GSimpleAsyncResult *simple;
}
else
{
- g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
- g_buffered_input_stream_fill_async (bstream, priv->len,
- io_priority, cancellable,
- skip_fill_buffer_callback, simple);
+ class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
+ class->fill_async (bstream, priv->len, io_priority, cancellable,
+ skip_fill_buffer_callback, simple);
}
}
GCancellable *cancellable,
GError **error)
{
+ GOutputStreamClass *class = G_OUTPUT_STREAM_GET_CLASS (stream);
gssize n_read, n_written;
gssize bytes_copied;
char buffer[8192], *p;
gboolean res;
+ if (class->write == NULL)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Output stream doesn't implement write"));
+ res = FALSE;
+ goto notsupported;
+ }
+
bytes_copied = 0;
res = TRUE;
do
p = buffer;
while (n_read > 0)
{
- stream->priv->pending = FALSE;
- n_written = g_output_stream_write (stream, p, n_read, cancellable, error);
- stream->priv->pending = TRUE;
+ n_written = class->write (stream, p, n_read, cancellable, error);
if (n_written == -1)
{
res = FALSE;
}
while (res);
+ notsupported:
if (!res)
error = NULL; /* Ignore further errors */
if (flags & G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET)
{
/* But write errors on close are bad! */
- stream->priv->pending = FALSE;
- if (!g_output_stream_close (stream, cancellable, error))
+ if (!class->close (stream, cancellable, error))
res = FALSE;
- stream->priv->pending = TRUE;
}
if (res)
return FALSE;
}
- res = g_output_stream_flush (stream, cancellable, error);
-
stream->priv->pending = TRUE;
if (cancellable)
g_push_current_cancellable (cancellable);
+ res = class->flush (stream, cancellable, error);
+
if (!res)
{
/* flushing caused the error that we want to return,
class = G_OUTPUT_STREAM_GET_CLASS (object);
op = g_simple_async_result_get_op_res_gpointer (result);
- stream->priv->pending = FALSE;
- op->bytes_copied =
- g_output_stream_splice (stream,
- op->source,
- op->flags,
- cancellable,
- &error);
- stream->priv->pending = TRUE;
+ op->bytes_copied = class->splice (stream,
+ op->source,
+ op->flags,
+ cancellable,
+ &error);
if (op->bytes_copied == -1)
{