Gio.pollable_stream_read

function pollable_stream_read(stream: Gio.InputStream, buffer: void, count: Number(gsize), blocking: Boolean, cancellable: Gio.Cancellable): Number(gssize) {
    // Gjs wrapper for g_pollable_stream_read()
}
  

Tries to read from stream, as with Gio.InputStream.prototype.read (if blocking is true) or Gio.PollableInputStream.prototype.read_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.PollableInputStream for which Gio.PollableInputStream.prototype.can_poll returns true, or else the behavior is undefined. If blocking is true, then stream does not need to be a Gio.PollableInputStream.

Since 2.34

stream

a Gio.InputStream

buffer

a buffer to read data into

count

the number of bytes to read

blocking

whether to do blocking I/O

cancellable

optional Gio.Cancellable object, null to ignore.

Returns

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