W Wrapl, The Programming Language

Libraries:Gtk:Gio:GInputStream

Types

T

Inherits from:

GInputStream has functions to read from a stream (Read), to close a stream (Close) and to skip some content (Skip).

To copy the content of an input stream to an output stream without manually handling the reads and writes, use Gtk.Gio.GOutputStream.Splice.

All of these functions have async variants too.



Constants

Nil : T

Functions

GetType() : Gtk.GObject.Type.T



Methods

:ClearPending(self @ T) : Std.Object.T

Clears the pending flag on stream.

stream input stream


:Close(self @ T, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Symbol.T

Closes the stream, releasing resources related to it.

Once the stream is closed, all other operations will return Gtk.Gio.GIOErrorEnum.Closed. Closing a stream multiple times will not return an error.

Streams will be automatically closed when the last reference is dropped, but you might want to call this function to make sure resources are released as early as possible.

Some streams might keep the backing store of the stream (e.g. a file descriptor) open after the stream is closed. See the documentation for the individual stream for details.

On failure the first error that happened will be reported, but the close operation will finish as much as possible. A stream that failed to close will still return Gtk.Gio.GIOErrorEnum.Closed for all operations. Still, it is important to check and report the error to the user.

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

stream A T.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns TRUE on success, FALSE on failure


:CloseAsync(self @ T, io_priority @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, callback @ Std.Function.T, user_data) : Std.Object.T

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 CloseFinish to get the result of the operation.

For behaviour details see Close.

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

stream A T.
io_priority the I/O priority of the request.
cancellable optional cancellable object. [allow-none]
callback callback to call when the request is satisfied. [scope async]
user_data the data to pass to callback function. [closure]


:CloseFinish(self @ T, result @ Gtk.Gio.GAsyncResult.T, error @ Std.Object.T) : Std.Symbol.T

Finishes closing a stream asynchronously, started from CloseAsync.

stream a T.
result a Gtk.Gio.GAsyncResult.T.
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns TRUE if the stream was closed successfully.


:HasPending(self @ T) : Std.Symbol.T

Checks if an input stream has pending actions.

stream input stream.
Returns TRUE if stream has pending actions.


:IsClosed(self @ T) : Std.Symbol.T

Checks if an input stream is closed.

stream input stream.
Returns TRUE if the stream is closed.


:Priv(self @ T) : Std.Object.T

:Read(self @ T, buffer @ Std.Address.T, count @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Integer.SmallT

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

If count is zero returns zero and does nothing. A value of count larger than G_MAXSSIZE will cause a Gtk.Gio.GIOErrorEnum.InvalidArgument error.

On success, the number of bytes read into the buffer is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. near the end of a file. Zero is returned on end of file (or if count is zero), but never otherwise.

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

On error -1 is returned and error is set accordingly.

stream a T.
buffer a buffer to read data into (which should be at least count bytes long).
count the number of bytes that will be read from the stream
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns Number of bytes read, or -1 on error


:ReadAll(self @ T, buffer @ Std.Address.T, count @ Std.Integer.SmallT, bytes_read @ Std.Object.T, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Symbol.T

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

This function is similar to Read, except it tries to read as many bytes as requested, only stopping on an error or end of stream.

On a successful read of count bytes, or if we reached the end of the stream, TRUE is returned, and bytes_read is set to the number of bytes read into buffer.

If there is an error during the operation FALSE is returned and error is set to indicate the error status, bytes_read is updated to contain the number of bytes read into buffer before the error occurred.

stream a T.
buffer a buffer to read data into (which should be at least count bytes long).
count the number of bytes that will be read from the stream
bytes_read location to store the number of bytes that was read from the stream. [out]
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns TRUE on success, FALSE if there was an error


:ReadAsync(self @ T, buffer @ Std.Address.T, count @ Std.Integer.SmallT, io_priority @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, callback @ Std.Function.T, user_data) : Std.Object.T

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 ReadFinish to get the result of the operation.

During an async request no other sync and async calls are allowed on stream, and will result in Gtk.Gio.GIOErrorEnum.Pending errors.

A value of count larger than G_MAXSSIZE will cause a Gtk.Gio.GIOErrorEnum.InvalidArgument error.

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

Any outstanding i/o request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is G_PRIORITY_DEFAULT.

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

stream A T.
buffer a buffer to read data into (which should be at least count bytes long).
count the number of bytes that will be read from the stream
io_priority the I/O priority of the request.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
callback callback to call when the request is satisfied. [scope async]
user_data the data to pass to callback function. [closure]


:ReadFinish(self @ T, result @ Gtk.Gio.GAsyncResult.T, error @ Std.Object.T) : Std.Integer.SmallT

Finishes an asynchronous stream read operation.

stream a T.
result a Gtk.Gio.GAsyncResult.T.
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns number of bytes read in, or -1 on error.


:SetPending(self @ T, error @ Std.Object.T) : Std.Symbol.T

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

stream input stream
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns TRUE if pending was previously unset and is now set.


:Skip(self @ T, count @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Integer.SmallT

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

This is identical to Read, from a behaviour standpoint, but the bytes that are skipped are not returned to the user. Some streams have an implementation that is more efficient than reading the data.

This function is optional for inherited classes, as the default implementation emulates it using read.

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

stream a T.
count the number of bytes that will be skipped from the stream
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns Number of bytes skipped, or -1 on error


:SkipAsync(self @ T, count @ Std.Integer.SmallT, io_priority @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, callback @ Std.Function.T, user_data) : Std.Object.T

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

During an async request no other sync and async calls are allowed, and will result in Gtk.Gio.GIOErrorEnum.Pending errors.

A value of count larger than G_MAXSSIZE will cause a Gtk.Gio.GIOErrorEnum.InvalidArgument error.

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

Any outstanding i/o request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is G_PRIORITY_DEFAULT.

The asynchronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one, you must override all.

stream A T.
count the number of bytes that will be skipped from the stream
io_priority the I/O priority of the request.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
callback callback to call when the request is satisfied. [scope async]
user_data the data to pass to callback function. [closure]


:SkipFinish(self @ T, result @ Gtk.Gio.GAsyncResult.T, error @ Std.Object.T) : Std.Integer.SmallT

Finishes a stream skip operation.

stream a T.
result a Gtk.Gio.GAsyncResult.T.
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns the size of the bytes skipped, or -1 on error.


:setPriv(self @ T, value @ Std.Object.T) : Std.Object.T