Gio.OutputStream.prototype.write_bytes

function write_bytes(bytes: ByteArray, cancellable: Gio.Cancellable): Number(gssize) {
    // Gjs wrapper for g_output_stream_write_bytes()
}
  

A wrapper function for Gio.OutputStream.prototype.write which takes a GLib.Bytes as input. This can be more convenient for use by language bindings or in other cases where the refcounted nature of GLib.Bytes is helpful over a bare pointer interface.

However, note that this function may still perform partial writes, just like Gio.OutputStream.prototype.write. If that occurs, to continue writing, you will need to create a new GLib.Bytes containing just the remaining bytes, using GLib.Bytes.prototype.new_from_bytes. Passing the same GLib.Bytes instance multiple times potentially can result in duplicated data in the output stream.

bytes

the GLib.Bytes to write

cancellable

optional cancellable object

Returns

Number of bytes written, or -1 on error