pollableStreamRead

fnptrdiff_t pollableStreamRead(gio.input_stream.InputStream stream, ubyte[] buffer, bool blocking, gio.cancellable.Cancellable cancellable = null)

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

streama #GInputStream
buffera buffer to read data into
blockingwhether to do blocking I/O
cancellableoptional #GCancellable object, null to ignore.

Returns

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

Throws

[ErrorWrap]