/* Returns: a #gssize containing the size of the data spliced, or -1 if an error occurred. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.  */
gssize g_output_stream_splice(GOutputStream *stream, GInputStream *source, GOutputStreamSpliceFlags flags, GCancellable *cancellable, GError **error)
/* Returns: a #gssize containing the size of the data spliced, or -1 if an error occurred. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.  */
gssize g_output_stream_splice(GOutputStream *stream, GInputStream *source, GOutputStreamSpliceFlags flags, GCancellable *cancellable, GError **error)
{
  GOutputStreamClass *class;
  gssize bytes_copied;
  g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
  g_return_val_if_fail (G_IS_INPUT_STREAM (source), -1);
  if (g_input_stream_is_closed (source))
    {
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
                           _("Source stream is already closed"));
      return -1;
    }
  if (!g_output_stream_set_pending (stream, error))
    return -1;
  class = G_OUTPUT_STREAM_GET_CLASS (stream);
  if (cancellable)
    g_cancellable_push_current (cancellable);
  bytes_copied = class->splice (stream, source, flags, cancellable, error);
  if (cancellable)
    g_cancellable_pop_current (cancellable);
  g_output_stream_clear_pending (stream);
  return bytes_copied;
}