Gio.pollable_stream_write

function pollable_stream_write(stream: Gio.OutputStream, buffer: ByteArray, blocking: Boolean, cancellable: Gio.Cancellable): Number(gssize) {
    // Gjs wrapper for g_pollable_stream_write()
}
  

Tries to write to stream, as with Gio.OutputStream.prototype.write (if blocking is true) or Gio.PollableOutputStream.prototype.write_nonblocking (if blocking is false). This can be used to more easily share code between blocking and non-blocking implementations of a method.

If blocking is false, then stream must be a Gio.PollableOutputStream for which Gio.PollableOutputStream.prototype.can_poll returns true or else the behavior is undefined. If blocking is true, then stream does not need to be a Gio.PollableOutputStream.

Since 2.34

stream

a Gio.OutputStream.

buffer

the buffer containing the data to write.

blocking

whether to do blocking I/O

cancellable

optional Gio.Cancellable object, null to ignore.

Returns

the number of bytes written, or -1 on error.