W Wrapl, The Programming Language

Libraries:Gtk:Gio:GOutputStream

Types

T

Inherits from:

GOutputStream has functions to write to a stream (Write), to close a stream (Close) and to flush pending writes (Flush).

To copy the content of an input stream to an output stream without manually handling the reads and writes, use 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 output 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.

Closing a stream will automatically flush any outstanding buffers in the stream.

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, otherwise there might be a loss of data as all data might not be written.

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 there some streams can use a faster close that doesn't block to e.g. check errors. On cancellation (as with any error) there is no guarantee that all written data will reach the target.

stream A T.
cancellable optional cancellable object. [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 close 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 io 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

Closes an output stream.

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 stream was successfully closed, FALSE otherwise.


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

Flushed any outstanding buffers in the stream. Will block during the operation. Closing the stream will implicitly cause a flush.

This function is optional for inherited classes.

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.

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


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

Flushes a stream asynchronously. For behaviour details see Flush.

When the operation is finished callback will be called. You can then call FlushFinish to get the result of the operation.

stream a T.
io_priority the io priority of the request.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
callback a Gtk.Gio.GAsyncReadyCallback to call when the request is satisfied. [scope async]
user_data the data to pass to callback function. [closure]


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

Finishes flushing an output stream.

stream a T.
result a GAsyncResult.
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns TRUE if flush operation succeeded, FALSE otherwise.


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

Checks if an ouput stream has pending actions.

stream a T.
Returns TRUE if stream has pending actions.


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

Checks if an output stream has already been closed.

stream a T.
Returns TRUE if stream is closed. FALSE otherwise.


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

Checks if an output stream is being closed. This can be used inside e.g. a flush implementation to see if the flush (or other i/o operation) is called from within the closing operation.

stream a T.
Returns TRUE if stream is being closed. FALSE otherwise.


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

: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 a T.
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.


:Splice(self @ T, source @ Gtk.Gio.GInputStream.T, flags @ Std.Integer.SmallT, cancellable @ Gtk.Gio.GCancellable.T, error @ Std.Object.T) : Std.Integer.SmallT

Splices an input stream into an output stream.

stream a T.
source a Gtk.Gio.GInputStream.T.
flags a set of Gtk.Gio.GOutputStreamSpliceFlags.T.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
error a Gtk.Glib.GError.T location to store the error occurring, or NULL to ignore.
Returns a gssize containing the size of the data spliced, or -1 if an error occurred. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.


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

Splices a stream asynchronously. When the operation is finished callback will be called. You can then call SpliceFinish to get the result of the operation.

For the synchronous, blocking version of this function, see Splice.

stream a T.
source a Gtk.Gio.GInputStream.T.
flags a set of Gtk.Gio.GOutputStreamSpliceFlags.T.
io_priority the io priority of the request.
cancellable optional Gtk.Gio.GCancellable.T object, NULL to ignore. [allow-none]
callback a Gtk.Gio.GAsyncReadyCallback. [scope async]
user_data user data passed to callback. [closure]


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

Finishes an asynchronous stream splice 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 a gssize of the number of bytes spliced. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.


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

Tries to write count bytes from buffer into the stream. Will block during the operation.

If count is 0, returns 0 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 written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, or if there is not enough storage in the stream. All writes block until at least one byte is written or an error occurs; 0 is never returned (unless count is 0).

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.

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

stream a T.
buffer the buffer containing the data to write. [array length=count][element-type guint8]
count the number of bytes to write
cancellable optional cancellable object. [allow-none]
error location to store the error occurring, or NULL to ignore
Returns Number of bytes written, or -1 on error


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

Tries to write count bytes from buffer into the stream. Will block during the operation.

This function is similar to Write, except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of count bytes, TRUE is returned, and bytes_written is set to count.

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

stream a T.
buffer the buffer containing the data to write. [array length=count][element-type guint8]
count the number of bytes to write
bytes_written location to store the number of bytes that was written to 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


:WriteAsync(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 write of count bytes from buffer into the stream. When the operation is finished callback will be called. You can then call WriteFinish 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 written 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. on a partial I/O error, but generally we try to write as many bytes as requested.

You are guaranteed that this method will never fail with Gtk.Gio.GIOErrorEnum.WouldBlock - if stream can't accept more data, the method will just wait until this changes.

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.

For the synchronous, blocking version of this function, see Write.

stream A T.
buffer the buffer containing the data to write. [array length=count][element-type guint8]
count the number of bytes to write
io_priority the io 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]


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

Finishes a stream write 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 a gssize containing the number of bytes written to the stream.


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