pollableStreamRead

Tries to read from stream, as with gio.input_stream.InputStream.read (if blocking is true) or gio.pollable_input_stream.PollableInputStream.readNonblocking (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 #GPollableInputStream for which gio.pollable_input_stream.PollableInputStream.canPoll returns true, or else the behavior is undefined. If blocking is true, then stream does not need to be a #GPollableInputStream.

Parameters

stream gio.input_stream.InputStream

a #GInputStream

buffer ubyte[]

a buffer to read data into

blocking bool

whether to do blocking I/O

cancellable gio.cancellable.Cancellable

optional #GCancellable object, null to ignore.

Return Value

Type: ptrdiff_t

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