Function

Giopollable_stream_read

since: 2.34

Declaration [src]

gssize
g_pollable_stream_read (
  GInputStream* stream,
  void* buffer,
  gsize count,
  gboolean blocking,
  GCancellable* cancellable,
  GError** error
)

Description [src]

Tries to read from stream, as with g_input_stream_read() (if blocking is TRUE) or g_pollable_input_stream_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 GPollableInputStream for which g_pollable_input_stream_can_poll() returns TRUE, or else the behavior is undefined. If blocking is TRUE, then stream does not need to be a GPollableInputStream.

Available since: 2.34

Parameters

stream

Type: GInputStream

A GInputStream.

The data is owned by the caller of the function.
buffer

Type: An array of guint8

A buffer to read data into.

The length of the array is specified in the count argument.
The data is owned by the caller of the function.
count

Type: gsize

The number of bytes to read.

blocking

Type: gboolean

Whether to do blocking I/O.

cancellable

Type: GCancellable

Optional GCancellable object, NULL to ignore.

The argument can be NULL.
The data is owned by the caller of the function.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gssize

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