Class: Gio::IOStream

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#clear_pendingnil

Clears the pending flag on stream.

Returns:

  • (nil)

#close(cancellable) ⇒ TrueClass

Closes the stream, releasing resources related to it. This will also close the individual input and output streams, if they are not already closed.

Once the stream is closed, all other operations will return %G_IO_ERROR_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 %G_IO_ERROR_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 %G_IO_ERROR_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.

The default implementation of this method just calls close on the individual input/output streams.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

Returns:

  • (TrueClass)

    true on success, false on failure

#close_async(io_priority, cancellable, callback, user_data) ⇒ nil

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 g_io_stream_close_finish() to get the result of the operation.

For behaviour details see g_io_stream_close().

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.

Parameters:

  • io_priority (Integer)

    the io priority of the request

  • cancellable (Gio::Cancellable)

    optional cancellable object

  • callback (Gio::AsyncReadyCallback)

    callback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#close_finish(result) ⇒ TrueClass

Closes a stream.

Parameters:

Returns:

  • (TrueClass)

    true if stream was successfully closed, false otherwise.

#closed=(closed) ⇒ TrueClass

Parameters:

  • closed (TrueClass)

Returns:

  • (TrueClass)

    closed

  • (TrueClass)

    closed

#closed?TrueClass

Returns closed.

Returns:

  • (TrueClass)

    closed

#has_pendingTrueClass

Checks if a stream has pending actions.

Returns:

  • (TrueClass)

    true if stream has pending actions.

#input_streamGio::InputStream

Returns input-stream.

Returns:

#input_stream=(input_stream) ⇒ Gio::InputStream

Parameters:

Returns:

#is_closedTrueClass

Checks if a stream is closed.

Returns:

  • (TrueClass)

    true if the stream is closed.

#output_streamGio::OutputStream

Returns output-stream.

Returns:

#output_stream=(output_stream) ⇒ Gio::OutputStream

Parameters:

Returns:

#set_pendingTrueClass

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

Returns:

  • (TrueClass)

    true if pending was previously unset and is now set.

#splice_async(stream2, flags, io_priority, cancellable, callback, user_data) ⇒ nil

Asyncronously splice the output stream of stream1 to the input stream of stream2, and splice the output stream of stream2 to the input stream of stream1.

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

Parameters:

  • stream2 (Gio::IOStream)

    a #GIOStream.

  • flags (Gio::IOStreamSpliceFlags)

    a set of GIOStream::SpliceFlags.

  • io_priority (Integer)

    the io priority of the request.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)