InputStream

GInputStream has functions to read from a stream (g_input_stream_read()), to close a stream (g_input_stream_close()) and to skip some content (g_input_stream_skip()).

To copy the content of an input stream to an output stream without manually handling the reads and writes, use g_output_stream_splice().

See the documentation for GIOStream for details of thread safety of streaming APIs.

All of these functions have async variants too.

Constructors

this
this(GInputStream* gInputStream, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

Members

Functions

clearPending
void clearPending()

Clears the pending flag on stream.

close
bool close(Cancellable cancellable)

Closes the stream, releasing resources related to it.

closeAsync
void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Requests an asynchronous closes of the stream, releasing resources related to it. When the operation is finished callback will be called. You can then call g_input_stream_close_finish() to get the result of the operation.

closeFinish
bool closeFinish(AsyncResultIF result)

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

getInputStreamStruct
GInputStream* getInputStreamStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

hasPending
bool hasPending()

Checks if an input stream has pending actions.

isClosed
bool isClosed()

Checks if an input stream is closed.

read
ptrdiff_t read(ubyte[] buffer, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer starting at buffer. Will block during this read.

readAll
bool readAll(ubyte[] buffer, out size_t bytesRead, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer starting at buffer. Will block during this read.

readAllAsync
void readAllAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous read of count bytes from the stream into the buffer starting at buffer.

readAllFinish
bool readAllFinish(AsyncResultIF result, out size_t bytesRead)

Finishes an asynchronous stream read operation started with g_input_stream_read_all_async().

readAsync
void readAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

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

readBytes
Bytes readBytes(size_t count, Cancellable cancellable)

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

readBytesAsync
void readBytesAsync(size_t count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

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

readBytesFinish
Bytes readBytesFinish(AsyncResultIF result)

Finishes an asynchronous stream read-into-GBytes operation.

readFinish
ptrdiff_t readFinish(AsyncResultIF result)

Finishes an asynchronous stream read operation.

setPending
bool setPending()

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

skip
ptrdiff_t skip(size_t count, Cancellable cancellable)

Tries to skip count bytes from the stream. Will block during the operation.

skipAsync
void skipAsync(size_t count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous skip of count bytes from the stream. When the operation is finished callback will be called. You can then call g_input_stream_skip_finish() to get the result of the operation.

skipFinish
ptrdiff_t skipFinish(AsyncResultIF result)

Finishes a stream skip operation.

Static functions

getType
GType getType()

Variables

gInputStream
GInputStream* gInputStream;

the main Gtk struct