Blame docs/reference/gio/html/GInputStream.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>GInputStream: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="streaming.html" title="Streaming I/O">
Packit ae235b
<link rel="prev" href="GSeekable.html" title="GSeekable">
Packit ae235b
<link rel="next" href="GOutputStream.html" title="GOutputStream">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description  | 
Packit ae235b
                  Object Hierarchy  | 
Packit ae235b
                  Known Derived Interfaces
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

GInputStream

Packit ae235b

GInputStream — Base class for implementing streaming input

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gssize
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_all ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_all_async ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_all_finish ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gssize
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_skip ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_close ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_async ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gssize
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_finish ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_skip_async ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gssize
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_skip_finish ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_close_async ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_close_finish ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_is_closed ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_has_pending ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_set_pending ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_clear_pending ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GBytes *
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_bytes ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_bytes_async ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GBytes *
Packit ae235b
Packit ae235b
Packit ae235b
g_input_stream_read_bytes_finish ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GInputStream
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Object Hierarchy

Packit ae235b
    GObject
Packit ae235b
    ╰── GInputStream
Packit ae235b
        ├── GFilterInputStream
Packit ae235b
        ├── GFileInputStream
Packit ae235b
        ├── GMemoryInputStream
Packit ae235b
        ╰── GUnixInputStream
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Known Derived Interfaces

Packit ae235b

Packit ae235b
GInputStream is required by
Packit ae235b
 GPollableInputStream.

Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gio/gio.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

GInputStream has functions to read from a stream (g_input_stream_read()),

Packit ae235b
to close a stream (g_input_stream_close()) and to skip some content
Packit ae235b
(g_input_stream_skip()). 

Packit ae235b

To copy the content of an input stream to an output stream without

Packit ae235b
manually handling the reads and writes, use g_output_stream_splice().

Packit ae235b

See the documentation for GIOStream for details of thread safety of

Packit ae235b
streaming APIs.

Packit ae235b

All of these functions have async variants too.

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_input_stream_read ()

Packit ae235b
gssize
Packit ae235b
g_input_stream_read (GInputStream *stream,
Packit ae235b
                     void *buffer,
Packit ae235b
                     gsize count,
Packit ae235b
                     GCancellable *cancellable,
Packit ae235b
                     GError **error);
Packit ae235b

Tries to read count

Packit ae235b
 bytes from the stream into the buffer starting at
Packit ae235b
buffer
Packit ae235b
. Will block during this read.

Packit ae235b

If count is zero returns zero and does nothing. A value of count

Packit ae235b
Packit ae235b
larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.

Packit ae235b

On success, the number of bytes read into the buffer is returned.

Packit ae235b
It is not an error if this is not the same as the requested size, as it
Packit ae235b
can happen e.g. near the end of a file. Zero is returned on end of file
Packit ae235b
(or if count
Packit ae235b
 is zero),  but never otherwise.

Packit ae235b

The returned buffer

Packit ae235b
 is not a nul-terminated string, it can contain nul bytes
Packit ae235b
at any position, and this function doesn't nul-terminate the buffer
Packit ae235b
.

Packit ae235b

If cancellable

Packit ae235b
 is not NULL, then the operation can be cancelled by
Packit ae235b
triggering the cancellable object from another thread. If the operation
Packit ae235b
was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
Packit ae235b
operation was partially finished when the operation was cancelled the
Packit ae235b
partial result will be returned, without an error.

Packit ae235b

On error -1 is returned and error

Packit ae235b
 is set accordingly.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

buffer

Packit ae235b

a buffer to

Packit ae235b
read data into (which should be at least count bytes long). 

Packit ae235b
[array length=count][element-type guint8]
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be read from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

Number of bytes read, or -1 on error, or 0 on end of file.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_all ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_read_all (GInputStream *stream,
Packit ae235b
                         void *buffer,
Packit ae235b
                         gsize count,
Packit ae235b
                         gsize *bytes_read,
Packit ae235b
                         GCancellable *cancellable,
Packit ae235b
                         GError **error);
Packit ae235b

Tries to read count

Packit ae235b
 bytes from the stream into the buffer starting at
Packit ae235b
buffer
Packit ae235b
. Will block during this read.

Packit ae235b

This function is similar to g_input_stream_read(), except it tries to

Packit ae235b
read as many bytes as requested, only stopping on an error or end of stream.

Packit ae235b

On a successful read of count

Packit ae235b
 bytes, or if we reached the end of the
Packit ae235b
stream,  TRUE is returned, and bytes_read
Packit ae235b
 is set to the number of bytes
Packit ae235b
read into buffer
Packit ae235b
.

Packit ae235b

If there is an error during the operation FALSE is returned and error

Packit ae235b
Packit ae235b
is set to indicate the error status.

Packit ae235b

As a special exception to the normal conventions for functions that

Packit ae235b
use GError, if this function returns FALSE (and sets error
Packit ae235b
) then
Packit ae235b
bytes_read
Packit ae235b
 will be set to the number of bytes that were successfully
Packit ae235b
read before the error was encountered.  This functionality is only
Packit ae235b
available from C.  If you need it from another language then you must
Packit ae235b
write your own loop around g_input_stream_read().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

buffer

Packit ae235b

a buffer to

Packit ae235b
read data into (which should be at least count bytes long). 

Packit ae235b
[array length=count][element-type guint8]
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be read from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

bytes_read

Packit ae235b

location to store the number of bytes that was read from the stream.

Packit ae235b
[out]
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE on success, FALSE if there was an error

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_all_async ()

Packit ae235b
void
Packit ae235b
g_input_stream_read_all_async (GInputStream *stream,
Packit ae235b
                               void *buffer,
Packit ae235b
                               gsize count,
Packit ae235b
                               int io_priority,
Packit ae235b
                               GCancellable *cancellable,
Packit ae235b
                               GAsyncReadyCallback callback,
Packit ae235b
                               gpointer user_data);
Packit ae235b

Request an asynchronous read of count

Packit ae235b
 bytes from the stream into the
Packit ae235b
buffer starting at buffer
Packit ae235b
.

Packit ae235b

This is the asynchronous equivalent of g_input_stream_read_all().

Packit ae235b

Call g_input_stream_read_all_finish() to collect the result.

Packit ae235b

Any outstanding I/O request with higher priority (lower numerical

Packit ae235b
value) will be executed before an outstanding request with lower
Packit ae235b
priority. Default priority is G_PRIORITY_DEFAULT.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

buffer

Packit ae235b

a buffer to

Packit ae235b
read data into (which should be at least count bytes long). 

Packit ae235b
[array length=count][element-type guint8]
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be read from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

io_priority

Packit ae235b

the I/O priority of the request

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

callback

Packit ae235b

callback to call when the request is satisfied.

Packit ae235b
[scope async]
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

the data to pass to callback function.

Packit ae235b
[closure]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.44

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_all_finish ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_read_all_finish (GInputStream *stream,
Packit ae235b
                                GAsyncResult *result,
Packit ae235b
                                gsize *bytes_read,
Packit ae235b
                                GError **error);
Packit ae235b

Finishes an asynchronous stream read operation started with

Packit ae235b
g_input_stream_read_all_async().

Packit ae235b

As a special exception to the normal conventions for functions that

Packit ae235b
use GError, if this function returns FALSE (and sets error
Packit ae235b
) then
Packit ae235b
bytes_read
Packit ae235b
 will be set to the number of bytes that were successfully
Packit ae235b
read before the error was encountered.  This functionality is only
Packit ae235b
available from C.  If you need it from another language then you must
Packit ae235b
write your own loop around g_input_stream_read_async().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

result

Packit ae235b

a GAsyncResult

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

bytes_read

Packit ae235b

location to store the number of bytes that was read from the stream.

Packit ae235b
[out]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE on success, FALSE if there was an error

Packit ae235b
Packit ae235b

Since: 2.44

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_skip ()

Packit ae235b
gssize
Packit ae235b
g_input_stream_skip (GInputStream *stream,
Packit ae235b
                     gsize count,
Packit ae235b
                     GCancellable *cancellable,
Packit ae235b
                     GError **error);
Packit ae235b

Tries to skip count

Packit ae235b
 bytes from the stream. Will block during the operation.

Packit ae235b

This is identical to g_input_stream_read(), from a behaviour standpoint,

Packit ae235b
but the bytes that are skipped are not returned to the user. Some
Packit ae235b
streams have an implementation that is more efficient than reading the data.

Packit ae235b

This function is optional for inherited classes, as the default implementation

Packit ae235b
emulates it using read.

Packit ae235b

If cancellable

Packit ae235b
 is not NULL, then the operation can be cancelled by
Packit ae235b
triggering the cancellable object from another thread. If the operation
Packit ae235b
was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
Packit ae235b
operation was partially finished when the operation was cancelled the
Packit ae235b
partial result will be returned, without an error.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be skipped from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

Number of bytes skipped, or -1 on error

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_close ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_close (GInputStream *stream,
Packit ae235b
                      GCancellable *cancellable,
Packit ae235b
                      GError **error);
Packit ae235b

Closes the stream, releasing resources related to it.

Packit ae235b

Once the stream is closed, all other operations will return G_IO_ERROR_CLOSED.

Packit ae235b
Closing a stream multiple times will not return an error.

Packit ae235b

Streams will be automatically closed when the last reference

Packit ae235b
is dropped, but you might want to call this function to make sure 
Packit ae235b
resources are released as early as possible.

Packit ae235b

Some streams might keep the backing store of the stream (e.g. a file descriptor)

Packit ae235b
open after the stream is closed. See the documentation for the individual
Packit ae235b
stream for details.

Packit ae235b

On failure the first error that happened will be reported, but the close

Packit ae235b
operation will finish as much as possible. A stream that failed to
Packit ae235b
close will still return G_IO_ERROR_CLOSED for all operations. Still, it
Packit ae235b
is important to check and report the error to the user.

Packit ae235b

If cancellable

Packit ae235b
 is not NULL, then the operation can be cancelled by
Packit ae235b
triggering the cancellable object from another thread. If the operation
Packit ae235b
was cancelled, the error G_IO_ERROR_CANCELLED will be returned.
Packit ae235b
Cancelling a close will still leave the stream closed, but some streams
Packit ae235b
can use a faster close that doesn't block to e.g. check errors.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE on success, FALSE on failure

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_async ()

Packit ae235b
void
Packit ae235b
g_input_stream_read_async (GInputStream *stream,
Packit ae235b
                           void *buffer,
Packit ae235b
                           gsize count,
Packit ae235b
                           int io_priority,
Packit ae235b
                           GCancellable *cancellable,
Packit ae235b
                           GAsyncReadyCallback callback,
Packit ae235b
                           gpointer user_data);
Packit ae235b

Request an asynchronous read of count

Packit ae235b
 bytes from the stream into the buffer
Packit ae235b
starting at buffer
Packit ae235b
. When the operation is finished callback
Packit ae235b
 will be called. 
Packit ae235b
You can then call g_input_stream_read_finish() to get the result of the 
Packit ae235b
operation.

Packit ae235b

During an async request no other sync and async calls are allowed on stream

Packit ae235b
, and will
Packit ae235b
result in G_IO_ERROR_PENDING errors. 

Packit ae235b

A value of count

Packit ae235b
 larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.

Packit ae235b

On success, the number of bytes read into the buffer will be passed to the

Packit ae235b
callback. It is not an error if this is not the same as the requested size, as it
Packit ae235b
can happen e.g. near the end of a file, but generally we try to read
Packit ae235b
as many bytes as requested. Zero is returned on end of file
Packit ae235b
(or if count
Packit ae235b
 is zero),  but never otherwise.

Packit ae235b

Any outstanding i/o request with higher priority (lower numerical value) will

Packit ae235b
be executed before an outstanding request with lower priority. Default
Packit ae235b
priority is G_PRIORITY_DEFAULT.

Packit ae235b

The asynchronous methods have a default fallback that uses threads to implement

Packit ae235b
asynchronicity, so they are optional for inheriting classes. However, if you
Packit ae235b
override one you must override all.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

buffer

Packit ae235b

a buffer to

Packit ae235b
read data into (which should be at least count bytes long). 

Packit ae235b
[array length=count][element-type guint8]
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be read from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

io_priority

Packit ae235b

the I/O priority

Packit ae235b
of the request. 

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

callback

Packit ae235b

callback to call when the request is satisfied.

Packit ae235b
[scope async]
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

the data to pass to callback function.

Packit ae235b
[closure]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_finish ()

Packit ae235b
gssize
Packit ae235b
g_input_stream_read_finish (GInputStream *stream,
Packit ae235b
                            GAsyncResult *result,
Packit ae235b
                            GError **error);
Packit ae235b

Finishes an asynchronous stream read operation.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

result

Packit ae235b

a GAsyncResult.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to

Packit ae235b
ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

number of bytes read in, or -1 on error, or 0 on end of file.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_skip_async ()

Packit ae235b
void
Packit ae235b
g_input_stream_skip_async (GInputStream *stream,
Packit ae235b
                           gsize count,
Packit ae235b
                           int io_priority,
Packit ae235b
                           GCancellable *cancellable,
Packit ae235b
                           GAsyncReadyCallback callback,
Packit ae235b
                           gpointer user_data);
Packit ae235b

Request an asynchronous skip of count

Packit ae235b
 bytes from the stream.
Packit ae235b
When the operation is finished callback
Packit ae235b
 will be called.
Packit ae235b
You can then call g_input_stream_skip_finish() to get the result
Packit ae235b
of the operation.

Packit ae235b

During an async request no other sync and async calls are allowed,

Packit ae235b
and will result in G_IO_ERROR_PENDING errors.

Packit ae235b

A value of count

Packit ae235b
 larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.

Packit ae235b

On success, the number of bytes skipped will be passed to the callback.

Packit ae235b
It is not an error if this is not the same as the requested size, as it
Packit ae235b
can happen e.g. near the end of a file, but generally we try to skip
Packit ae235b
as many bytes as requested. Zero is returned on end of file
Packit ae235b
(or if count
Packit ae235b
 is zero), but never otherwise.

Packit ae235b

Any outstanding i/o request with higher priority (lower numerical value)

Packit ae235b
will be executed before an outstanding request with lower priority.
Packit ae235b
Default priority is G_PRIORITY_DEFAULT.

Packit ae235b

The asynchronous methods have a default fallback that uses threads to

Packit ae235b
implement asynchronicity, so they are optional for inheriting classes.
Packit ae235b
However, if you override one, you must override all.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be skipped from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

io_priority

Packit ae235b

the I/O priority of the request

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

callback

Packit ae235b

callback to call when the request is satisfied.

Packit ae235b
[scope async]
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

the data to pass to callback function.

Packit ae235b
[closure]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_skip_finish ()

Packit ae235b
gssize
Packit ae235b
g_input_stream_skip_finish (GInputStream *stream,
Packit ae235b
                            GAsyncResult *result,
Packit ae235b
                            GError **error);
Packit ae235b

Finishes a stream skip operation.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

result

Packit ae235b

a GAsyncResult.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to

Packit ae235b
ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the size of the bytes skipped, or -1 on error.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_close_async ()

Packit ae235b
void
Packit ae235b
g_input_stream_close_async (GInputStream *stream,
Packit ae235b
                            int io_priority,
Packit ae235b
                            GCancellable *cancellable,
Packit ae235b
                            GAsyncReadyCallback callback,
Packit ae235b
                            gpointer user_data);
Packit ae235b

Requests an asynchronous closes of the stream, releasing resources related to it.

Packit ae235b
When the operation is finished callback
Packit ae235b
 will be called. 
Packit ae235b
You can then call g_input_stream_close_finish() to get the result of the 
Packit ae235b
operation.

Packit ae235b

For behaviour details see g_input_stream_close().

Packit ae235b

The asynchronous methods have a default fallback that uses threads to implement

Packit ae235b
asynchronicity, so they are optional for inheriting classes. However, if you
Packit ae235b
override one you must override all.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

io_priority

Packit ae235b

the I/O priority of the request

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional cancellable object.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

callback

Packit ae235b

callback to call when the request is satisfied.

Packit ae235b
[scope async]
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

the data to pass to callback function.

Packit ae235b
[closure]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_close_finish ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_close_finish (GInputStream *stream,
Packit ae235b
                             GAsyncResult *result,
Packit ae235b
                             GError **error);
Packit ae235b

Finishes closing a stream asynchronously, started from g_input_stream_close_async().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

result

Packit ae235b

a GAsyncResult.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to

Packit ae235b
ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if the stream was closed successfully.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_is_closed ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_is_closed (GInputStream *stream);
Packit ae235b

Checks if an input stream is closed.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

input stream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if the stream is closed.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_has_pending ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_has_pending (GInputStream *stream);
Packit ae235b

Checks if an input stream has pending actions.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

input stream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if stream

Packit ae235b
has pending actions.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_set_pending ()

Packit ae235b
gboolean
Packit ae235b
g_input_stream_set_pending (GInputStream *stream,
Packit ae235b
                            GError **error);
Packit ae235b

Sets stream

Packit ae235b
 to have actions pending. If the pending flag is
Packit ae235b
already set or stream
Packit ae235b
 is closed, it will return FALSE and set
Packit ae235b
error
Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

input stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to

Packit ae235b
ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if pending was previously unset and is now set.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_clear_pending ()

Packit ae235b
void
Packit ae235b
g_input_stream_clear_pending (GInputStream *stream);
Packit ae235b

Clears the pending flag on stream

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

input stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_bytes ()

Packit ae235b
GBytes *
Packit ae235b
g_input_stream_read_bytes (GInputStream *stream,
Packit ae235b
                           gsize count,
Packit ae235b
                           GCancellable *cancellable,
Packit ae235b
                           GError **error);
Packit ae235b

Like g_input_stream_read(), this tries to read count

Packit ae235b
 bytes from
Packit ae235b
the stream in a blocking fashion. However, rather than reading into
Packit ae235b
a user-supplied buffer, this will create a new GBytes containing
Packit ae235b
the data that was read. This may be easier to use from language
Packit ae235b
bindings.

Packit ae235b

If count is zero, returns a zero-length GBytes and does nothing. A

Packit ae235b
value of count
Packit ae235b
 larger than G_MAXSSIZE will cause a
Packit ae235b
G_IO_ERROR_INVALID_ARGUMENT error.

Packit ae235b

On success, a new GBytes is returned. It is not an error if the

Packit ae235b
size of this object is not the same as the requested size, as it
Packit ae235b
can happen e.g. near the end of a file. A zero-length GBytes is
Packit ae235b
returned on end of file (or if count
Packit ae235b
 is zero), but never
Packit ae235b
otherwise.

Packit ae235b

If cancellable

Packit ae235b
 is not NULL, then the operation can be cancelled by
Packit ae235b
triggering the cancellable object from another thread. If the operation
Packit ae235b
was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
Packit ae235b
operation was partially finished when the operation was cancelled the
Packit ae235b
partial result will be returned, without an error.

Packit ae235b

On error NULL is returned and error

Packit ae235b
 is set accordingly.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

maximum number of bytes that will be read from the stream. Common

Packit ae235b
values include 4096 and 8192.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

location to store the error occurring, or NULL to ignore

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a new GBytes, or NULL on error.

Packit ae235b

[transfer full]

Packit ae235b
Packit ae235b

Since: 2.34

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_bytes_async ()

Packit ae235b
void
Packit ae235b
g_input_stream_read_bytes_async (GInputStream *stream,
Packit ae235b
                                 gsize count,
Packit ae235b
                                 int io_priority,
Packit ae235b
                                 GCancellable *cancellable,
Packit ae235b
                                 GAsyncReadyCallback callback,
Packit ae235b
                                 gpointer user_data);
Packit ae235b

Request an asynchronous read of count

Packit ae235b
 bytes from the stream into a
Packit ae235b
new GBytes. When the operation is finished callback
Packit ae235b
 will be
Packit ae235b
called. You can then call g_input_stream_read_bytes_finish() to get the
Packit ae235b
result of the operation.

Packit ae235b

During an async request no other sync and async calls are allowed

Packit ae235b
on stream
Packit ae235b
, and will result in G_IO_ERROR_PENDING errors.

Packit ae235b

A value of count

Packit ae235b
 larger than G_MAXSSIZE will cause a
Packit ae235b
G_IO_ERROR_INVALID_ARGUMENT error.

Packit ae235b

On success, the new GBytes will be passed to the callback. It is

Packit ae235b
not an error if this is smaller than the requested size, as it can
Packit ae235b
happen e.g. near the end of a file, but generally we try to read as
Packit ae235b
many bytes as requested. Zero is returned on end of file (or if
Packit ae235b
count
Packit ae235b
 is zero), but never otherwise.

Packit ae235b

Any outstanding I/O request with higher priority (lower numerical

Packit ae235b
value) will be executed before an outstanding request with lower
Packit ae235b
priority. Default priority is G_PRIORITY_DEFAULT.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

A GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

count

Packit ae235b

the number of bytes that will be read from the stream

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

io_priority

Packit ae235b

the I/O priority of the request

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

optional GCancellable object, NULL to ignore.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

callback

Packit ae235b

callback to call when the request is satisfied.

Packit ae235b
[scope async]
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

the data to pass to callback function.

Packit ae235b
[closure]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.34

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_input_stream_read_bytes_finish ()

Packit ae235b
GBytes *
Packit ae235b
g_input_stream_read_bytes_finish (GInputStream *stream,
Packit ae235b
                                  GAsyncResult *result,
Packit ae235b
                                  GError **error);
Packit ae235b

Finishes an asynchronous stream read-into-GBytes operation.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

stream

Packit ae235b

a GInputStream.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

result

Packit ae235b

a GAsyncResult.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

a GError location to store the error occurring, or NULL to

Packit ae235b
ignore.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the newly-allocated GBytes, or NULL on error.

Packit ae235b

[transfer full]

Packit ae235b
Packit ae235b

Since: 2.34

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GInputStream

Packit ae235b
typedef struct _GInputStream GInputStream;
Packit ae235b

Base class for streaming input operations.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>