OutputStream.writeBytes

ptrdiff_t writeBytes(glib.bytes.Bytes bytes, gio.cancellable.Cancellable cancellable = null)

A wrapper function for [gio.output_stream.OutputStream.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 [gio.output_stream.OutputStream.write]. If that occurs, to continue writing, you will need to create a new #GBytes containing just the remaining bytes, using [glib.bytes.Bytes.newFromBytes]. Passing the same #GBytes instance multiple times potentially can result in duplicated data in the output stream.

Parameters

bytesthe #GBytes to write
cancellableoptional cancellable object

Returns

Number of bytes written, or -1 on error

Throws

[ErrorWrap]