/* Returns: the number of bytes read into @stream's buffer, up to @count, or -1 on error.  */
gssize g_buffered_input_stream_fill(GBufferedInputStream *stream, gssize count, GCancellable *cancellable, GError **error)
/* Returns: the number of bytes read into @stream's buffer, up to @count, or -1 on error.  */
gssize g_buffered_input_stream_fill(GBufferedInputStream *stream, gssize count, GCancellable *cancellable, GError **error)
{
  GBufferedInputStreamClass *class;
  GInputStream *input_stream;
  gssize res;
  g_return_val_if_fail (G_IS_BUFFERED_INPUT_STREAM (stream), -1);
  input_stream = G_INPUT_STREAM (stream);
  if (count < -1)
    {
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                   _("Too large count value passed to %s"), G_STRFUNC);
      return -1;
    }
  if (!g_input_stream_set_pending (input_stream, error))
    return -1;
  if (cancellable)
    g_cancellable_push_current (cancellable);
  class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
  res = class->fill (stream, count, cancellable, error);
  if (cancellable)
    g_cancellable_pop_current (cancellable);
  g_input_stream_clear_pending (input_stream);
  return res;
}