g_output_stream_write_bytes (
  GOutputStream* stream,
  GBytes* bytes,
  GCancellable* cancellable,
  GError** error


A wrapper function for g_output_stream_write() which takes a GBytes as input. This can be more convenient for use by language bindings or in other cases where the refcounted nature of GBytes is helpful over a bare pointer interface.

However, note that this function may still perform partial writes, just like g_output_stream_write(). If that occurs, to continue writing, you will need to create a new GBytes containing just the remaining bytes, using g_bytes_new_from_bytes(). Passing the same GBytes instance multiple times potentially can result in duplicated data in the output stream.



Type: GBytes

The GBytes to write.

The data is owned by the caller of the function.

Type: GCancellable

Optional cancellable object.

The argument can be NULL.
The data is owned by the caller of the function.

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gssize

Number of bytes written, or -1 on error.