Gio.OutputStream

g GObject.Object GObject.Object Gio.OutputStream Gio.OutputStream GObject.Object->Gio.OutputStream

Subclasses:Gio.FileOutputStream, Gio.FilterOutputStream, Gio.MemoryOutputStream, Gio.UnixOutputStream

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
  clear_pending ()
  close (cancellable)
  close_async (io_priority, cancellable, callback, *user_data)
  close_finish (result)
  flush (cancellable)
  flush_async (io_priority, cancellable, callback, *user_data)
  flush_finish (result)
  has_pending ()
  is_closed ()
  is_closing ()
  set_pending ()
  splice (source, flags, cancellable)
  splice_async (source, flags, io_priority, cancellable, callback, *user_data)
  splice_finish (result)
  write (buffer, cancellable)
  write_all (buffer, cancellable)
  write_all_async (buffer, io_priority, cancellable, callback, *user_data)
  write_all_finish (result)
  write_async (buffer, io_priority, cancellable, callback, *user_data)
  write_bytes (bytes, cancellable)
  write_bytes_async (bytes, io_priority, cancellable, callback, *user_data)
  write_bytes_finish (result)
  write_finish (result)
  writev (vectors, cancellable)
  writev_all (vectors, cancellable)
  writev_all_async (vectors, io_priority, cancellable, callback, *user_data)
  writev_all_finish (result)
  writev_async (vectors, io_priority, cancellable, callback, *user_data)
  writev_finish (result)

Virtual Methods

Inherited:GObject.Object (7)
  do_close_async (io_priority, cancellable, callback, *user_data)
  do_close_finish (result)
  do_close_fn (cancellable)
  do_flush (cancellable)
  do_flush_async (io_priority, cancellable, callback, *user_data)
  do_flush_finish (result)
  do_splice (source, flags, cancellable)
  do_splice_async (source, flags, io_priority, cancellable, callback, *user_data)
  do_splice_finish (result)
  do_write_async (buffer, io_priority, cancellable, callback, *user_data)
  do_write_finish (result)
  do_write_fn (buffer, cancellable)
  do_writev_async (vectors, io_priority, cancellable, callback, *user_data)
  do_writev_finish (result)
  do_writev_fn (vectors, cancellable)

Properties

None

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)
Name Type Access Description
parent_instance GObject.Object r  

Class Details

class Gio.OutputStream(**kwargs)
Bases:GObject.Object
Abstract:Yes
Structure:Gio.OutputStreamClass

Gio.OutputStream has functions to write to a stream (Gio.OutputStream.write()), to close a stream (Gio.OutputStream.close()) and to flush pending writes (Gio.OutputStream.flush()).

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

See the documentation for Gio.IOStream for details of thread safety of streaming APIs.

All of these functions have async variants too.

clear_pending()[source]

Clears the pending flag on self.

close(cancellable)[source]
Parameters:cancellable (Gio.Cancellable or None) – optional cancellable object
Raises:GLib.Error
Returns:True on success, False on failure
Return type:bool

Closes the stream, releasing resources related to it.

Once the stream is closed, all other operations will return Gio.IOErrorEnum.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 Gio.IOErrorEnum.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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.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.

close_async(io_priority, cancellable, callback, *user_data)[source]
Parameters:

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

For behaviour details see Gio.OutputStream.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.

close_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:True if stream was successfully closed, False otherwise.
Return type:bool

Closes an output stream.

flush(cancellable)[source]
Parameters:cancellable (Gio.Cancellable or None) – optional cancellable object
Raises:GLib.Error
Returns:True on success, False on error
Return type:bool

Forces a write of all user-space buffered data for the given self. Will block during the operation. Closing the stream will implicitly cause a flush.

This function is optional for inherited classes.

If cancellable is not None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

flush_async(io_priority, cancellable, callback, *user_data)[source]
Parameters:

Forces an asynchronous write of all user-space buffered data for the given self. For behaviour details see Gio.OutputStream.flush().

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

flush_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:True if flush operation succeeded, False otherwise.
Return type:bool

Finishes flushing an output stream.

has_pending()[source]
Returns:True if self has pending actions.
Return type:bool

Checks if an output stream has pending actions.

is_closed()[source]
Returns:True if self is closed. False otherwise.
Return type:bool

Checks if an output stream has already been closed.

is_closing()[source]
Returns:True if self is being closed. False otherwise.
Return type:bool

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.

New in version 2.24.

set_pending()[source]
Raises:GLib.Error
Returns:True if pending was previously unset and is now set.
Return type:bool

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

splice(source, flags, cancellable)[source]
Parameters:
Raises:

GLib.Error

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 GObject.G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.

Return type:

int

Splices an input stream into an output stream.

splice_async(source, flags, io_priority, cancellable, callback, *user_data)[source]
Parameters:

Splices a stream asynchronously. When the operation is finished callback will be called. You can then call Gio.OutputStream.splice_finish() to get the result of the operation.

For the synchronous, blocking version of this function, see Gio.OutputStream.splice().

splice_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:a #gssize of the number of bytes spliced. Note that if the number of bytes spliced is greater than GObject.G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.
Return type:int

Finishes an asynchronous stream splice operation.

write(buffer, cancellable)[source]
Parameters:
  • buffer (bytes) – the buffer containing the data to write.
  • cancellable (Gio.Cancellable or None) – optional cancellable object
Raises:

GLib.Error

Returns:

Number of bytes written, or -1 on error

Return type:

int

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 GObject.G_MAXSSIZE will cause a Gio.IOErrorEnum.INVALID_ARGUMENT 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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.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.

write_all(buffer, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

True on success, False if there was an error

bytes_written:location to store the number of bytes that was written to the stream

Return type:

(bool, bytes_written: int)

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

This function is similar to Gio.OutputStream.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.

As a special exception to the normal conventions for functions that use GLib.Error, if this function returns False (and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around Gio.OutputStream.write().

write_all_async(buffer, io_priority, cancellable, callback, *user_data)[source]
Parameters:

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

This is the asynchronous version of Gio.OutputStream.write_all().

Call Gio.OutputStream.write_all_finish() to collect the result.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is GLib.PRIORITY_DEFAULT.

Note that no copy of buffer will be made, so it must stay valid until callback is called.

New in version 2.44.

write_all_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
Returns:True on success, False if there was an error
bytes_written:location to store the number of bytes that was written to the stream
Return type:(bool, bytes_written: int)

Finishes an asynchronous stream write operation started with Gio.OutputStream.write_all_async().

As a special exception to the normal conventions for functions that use GLib.Error, if this function returns False (and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around Gio.OutputStream.write_async().

New in version 2.44.

write_async(buffer, io_priority, cancellable, callback, *user_data)[source]
Parameters:

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

During an async request no other sync and async calls are allowed, and will result in Gio.IOErrorEnum.PENDING errors.

A value of count larger than GObject.G_MAXSSIZE will cause a Gio.IOErrorEnum.INVALID_ARGUMENT 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 Gio.IOErrorEnum.WOULD_BLOCK - if self 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 GLib.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.

For the synchronous, blocking version of this function, see Gio.OutputStream.write().

Note that no copy of buffer will be made, so it must stay valid until callback is called. See Gio.OutputStream.write_bytes_async() for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

write_bytes(bytes, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

Number of bytes written, or -1 on error

Return type:

int

A wrapper function for Gio.OutputStream.write() which takes a GLib.Bytes as input. This can be more convenient for use by language bindings or in other cases where the refcounted nature of GLib.Bytes is helpful over a bare pointer interface.

However, note that this function may still perform partial writes, just like Gio.OutputStream.write(). If that occurs, to continue writing, you will need to create a new GLib.Bytes containing just the remaining bytes, using GLib.Bytes.new_from_bytes(). Passing the same GLib.Bytes instance multiple times potentially can result in duplicated data in the output stream.

write_bytes_async(bytes, io_priority, cancellable, callback, *user_data)[source]
Parameters:

This function is similar to Gio.OutputStream.write_async(), but takes a GLib.Bytes as input. Due to the refcounted nature of GLib.Bytes, this allows the stream to avoid taking a copy of the data.

However, note that this function may still perform partial writes, just like Gio.OutputStream.write_async(). If that occurs, to continue writing, you will need to create a new GLib.Bytes containing just the remaining bytes, using GLib.Bytes.new_from_bytes(). Passing the same GLib.Bytes instance multiple times potentially can result in duplicated data in the output stream.

For the synchronous, blocking version of this function, see Gio.OutputStream.write_bytes().

write_bytes_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:a #gssize containing the number of bytes written to the stream.
Return type:int

Finishes a stream write-from-GLib.Bytes operation.

write_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:a #gssize containing the number of bytes written to the stream.
Return type:int

Finishes a stream write operation.

writev(vectors, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

True on success, False if there was an error

bytes_written:location to store the number of bytes that were written to the stream

Return type:

(bool, bytes_written: int)

Tries to write the bytes contained in the n_vectors vectors into the stream. Will block during the operation.

If n_vectors is 0 or the sum of all bytes in vectors is 0, returns 0 and does nothing.

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 n_vectors is 0 or the sum of all bytes in vectors is 0).

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

Some implementations of Gio.OutputStream.writev() may have limitations on the aggregate buffer size, and will return Gio.IOErrorEnum.INVALID_ARGUMENT if these are exceeded. For example, when writing to a local file on UNIX platforms, the aggregate buffer size must not exceed GObject.G_MAXSSIZE bytes.

New in version 2.60.

writev_all(vectors, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

True on success, False if there was an error

bytes_written:location to store the number of bytes that were written to the stream

Return type:

(bool, bytes_written: int)

Tries to write the bytes contained in the n_vectors vectors into the stream. Will block during the operation.

This function is similar to Gio.OutputStream.writev(), except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of all n_vectors vectors, True is returned, and bytes_written is set to the sum of all the sizes of vectors.

If there is an error during the operation False is returned and error is set to indicate the error status.

As a special exception to the normal conventions for functions that use GLib.Error, if this function returns False (and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around Gio.OutputStream.write().

The content of the individual elements of vectors might be changed by this function.

New in version 2.60.

writev_all_async(vectors, io_priority, cancellable, callback, *user_data)[source]
Parameters:

Request an asynchronous write of the bytes contained in the n_vectors vectors into the stream. When the operation is finished callback will be called. You can then call Gio.OutputStream.writev_all_finish() to get the result of the operation.

This is the asynchronous version of Gio.OutputStream.writev_all().

Call Gio.OutputStream.writev_all_finish() to collect the result.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is GLib.PRIORITY_DEFAULT.

Note that no copy of vectors will be made, so it must stay valid until callback is called. The content of the individual elements of vectors might be changed by this function.

New in version 2.60.

writev_all_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult
Raises:GLib.Error
Returns:True on success, False if there was an error
bytes_written:location to store the number of bytes that were written to the stream
Return type:(bool, bytes_written: int)

Finishes an asynchronous stream write operation started with Gio.OutputStream.writev_all_async().

As a special exception to the normal conventions for functions that use GLib.Error, if this function returns False (and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around Gio.OutputStream.writev_async().

New in version 2.60.

writev_async(vectors, io_priority, cancellable, callback, *user_data)[source]
Parameters:

Request an asynchronous write of the bytes contained in n_vectors vectors into the stream. When the operation is finished callback will be called. You can then call Gio.OutputStream.writev_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio.IOErrorEnum.PENDING errors.

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 Gio.IOErrorEnum.WOULD_BLOCK — if self 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 GLib.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.

For the synchronous, blocking version of this function, see Gio.OutputStream.writev().

Note that no copy of vectors will be made, so it must stay valid until callback is called.

New in version 2.60.

writev_finish(result)[source]
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Raises:GLib.Error
Returns:True on success, False if there was an error
bytes_written:location to store the number of bytes that were written to the stream
Return type:(bool, bytes_written: int)

Finishes a stream writev operation.

New in version 2.60.

do_close_async(io_priority, cancellable, callback, *user_data) virtual
Parameters:

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

For behaviour details see Gio.OutputStream.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.

do_close_finish(result) virtual
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Returns:True if stream was successfully closed, False otherwise.
Return type:bool

Closes an output stream.

do_close_fn(cancellable) virtual
Parameters:cancellable (Gio.Cancellable or None) –
Return type:bool
do_flush(cancellable) virtual
Parameters:cancellable (Gio.Cancellable or None) – optional cancellable object
Returns:True on success, False on error
Return type:bool

Forces a write of all user-space buffered data for the given 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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.CANCELLED will be returned.

do_flush_async(io_priority, cancellable, callback, *user_data) virtual
Parameters:

Forces an asynchronous write of all user-space buffered data for the given stream. For behaviour details see Gio.OutputStream.flush().

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

do_flush_finish(result) virtual
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Returns:True if flush operation succeeded, False otherwise.
Return type:bool

Finishes flushing an output stream.

do_splice(source, flags, cancellable) virtual
Parameters:
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 GObject.G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.

Return type:

int

Splices an input stream into an output stream.

do_splice_async(source, flags, io_priority, cancellable, callback, *user_data) virtual
Parameters:

Splices a stream asynchronously. When the operation is finished callback will be called. You can then call Gio.OutputStream.splice_finish() to get the result of the operation.

For the synchronous, blocking version of this function, see Gio.OutputStream.splice().

do_splice_finish(result) virtual
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Returns:a #gssize of the number of bytes spliced. Note that if the number of bytes spliced is greater than GObject.G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.
Return type:int

Finishes an asynchronous stream splice operation.

do_write_async(buffer, io_priority, cancellable, callback, *user_data) virtual
Parameters:

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

During an async request no other sync and async calls are allowed, and will result in Gio.IOErrorEnum.PENDING errors.

A value of count larger than GObject.G_MAXSSIZE will cause a Gio.IOErrorEnum.INVALID_ARGUMENT 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 Gio.IOErrorEnum.WOULD_BLOCK - 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 GLib.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.

For the synchronous, blocking version of this function, see Gio.OutputStream.write().

Note that no copy of buffer will be made, so it must stay valid until callback is called. See Gio.OutputStream.write_bytes_async() for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

do_write_finish(result) virtual
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Returns:a #gssize containing the number of bytes written to the stream.
Return type:int

Finishes a stream write operation.

do_write_fn(buffer, cancellable) virtual
Parameters:
Returns:

Number of bytes written, or -1 on error

Return type:

int

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 GObject.G_MAXSSIZE will cause a Gio.IOErrorEnum.INVALID_ARGUMENT 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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.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.

do_writev_async(vectors, io_priority, cancellable, callback, *user_data) virtual
Parameters:

Request an asynchronous write of the bytes contained in n_vectors vectors into the stream. When the operation is finished callback will be called. You can then call Gio.OutputStream.writev_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio.IOErrorEnum.PENDING errors.

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 Gio.IOErrorEnum.WOULD_BLOCK — 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 GLib.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.

For the synchronous, blocking version of this function, see Gio.OutputStream.writev().

Note that no copy of vectors will be made, so it must stay valid until callback is called.

New in version 2.60.

do_writev_finish(result) virtual
Parameters:result (Gio.AsyncResult) – a Gio.AsyncResult.
Returns:True on success, False if there was an error
bytes_written:location to store the number of bytes that were written to the stream
Return type:(bool, bytes_written: int)

Finishes a stream writev operation.

New in version 2.60.

do_writev_fn(vectors, cancellable) virtual
Parameters:
Returns:

True on success, False if there was an error

bytes_written:location to store the number of bytes that were written to the stream

Return type:

(bool, bytes_written: int)

Tries to write the bytes contained in the n_vectors vectors into the stream. Will block during the operation.

If n_vectors is 0 or the sum of all bytes in vectors is 0, returns 0 and does nothing.

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 n_vectors is 0 or the sum of all bytes in vectors is 0).

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

Some implementations of Gio.OutputStream.writev() may have limitations on the aggregate buffer size, and will return Gio.IOErrorEnum.INVALID_ARGUMENT if these are exceeded. For example, when writing to a local file on UNIX platforms, the aggregate buffer size must not exceed GObject.G_MAXSSIZE bytes.

New in version 2.60.