Gio.OutputStream¶
- Subclasses:
Gio.FileOutputStream
,Gio.FilterOutputStream
,Gio.MemoryOutputStream
,Gio.UnixOutputStream
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gio.OutputStream(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
GOutputStream
is a base class for implementing streaming output.It has functions to write to a stream ([method`Gio`.OutputStream.write]), to close a stream ([method`Gio`.OutputStream.close]) and to flush pending writes ([method`Gio`.OutputStream.flush]).
To copy the content of an input stream to an output stream without manually handling the reads and writes, use [method`Gio`.OutputStream.splice].
See the documentation for [class`Gio`.IOStream] for details of thread safety of streaming APIs.
All of these functions have async variants too.
All classes derived from
GOutputStream
*should* implement synchronous writing, splicing, flushing and closing streams, but *may* implement asynchronous versions.- close(cancellable)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellable object- Raises:
- Returns:
- Return type:
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 errorGio.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:
io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optional cancellable objectcallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Raises:
- Returns:
- Return type:
Closes an output stream.
- flush(cancellable)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellable object- Raises:
- Returns:
- Return type:
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 errorGio.IOErrorEnum.CANCELLED
will be returned.
- flush_async(io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Raises:
- Returns:
- Return type:
Finishes flushing an output stream.
- is_closing()[source]¶
-
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:
- Returns:
True
if pending was previously unset and is now set.- Return type:
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:
source (
Gio.InputStream
) – aGio.InputStream
.flags (
Gio.OutputStreamSpliceFlags
) – a set ofGio.OutputStreamSpliceFlags
.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.
- Raises:
- 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:
Splices an input stream into an output stream.
- splice_async(source, flags, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
source (
Gio.InputStream
) – aGio.InputStream
.flags (
Gio.OutputStreamSpliceFlags
) – a set ofGio.OutputStreamSpliceFlags
.io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Raises:
- 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:
Finishes an asynchronous stream splice operation.
- write(buffer, cancellable)[source]¶
- Parameters:
buffer (
bytes
) – the buffer containing the data to write.cancellable (
Gio.Cancellable
orNone
) – optional cancellable object
- Raises:
- Returns:
Number of bytes written, or -1 on error
- Return type:
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 aGio.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 errorGio.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:
buffer (
bytes
) – the buffer containing the data to write.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.
- Raises:
- 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:
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 returnsFalse
(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 aroundGio.OutputStream.write
().
- write_all_async(buffer, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
buffer (
bytes
) – the buffer containing the data to writeio_priority (
int
) – the io priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignorecallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
- Raises:
- 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:
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 returnsFalse
(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 aroundGio.OutputStream.write_async
().New in version 2.44.
- write_async(buffer, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
buffer (
bytes
) – the buffer containing the data to write.io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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 aGio.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 aGLib.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:
bytes (
GLib.Bytes
) – theGLib.Bytes
to writecancellable (
Gio.Cancellable
orNone
) – optional cancellable object
- Raises:
- Returns:
Number of bytes written, or -1 on error
- Return type:
A wrapper function for
Gio.OutputStream.write
() which takes aGLib.Bytes
as input. This can be more convenient for use by language bindings or in other cases where the refcounted nature ofGLib.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 newGLib.Bytes
containing just the remaining bytes, usingGLib.Bytes.new_from_bytes
(). Passing the sameGLib.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:
bytes (
GLib.Bytes
) – The bytes to writeio_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
This function is similar to
Gio.OutputStream.write_async
(), but takes aGLib.Bytes
as input. Due to the refcounted nature ofGLib.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 newGLib.Bytes
containing just the remaining bytes, usingGLib.Bytes.new_from_bytes
(). Passing the sameGLib.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
) – aGio.AsyncResult
.- Raises:
- Returns:
a #gssize containing the number of bytes written to the stream.
- Return type:
Finishes a stream write-from-
GLib.Bytes
operation.
- write_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
a #gssize containing the number of bytes written to the stream.
- Return type:
Finishes a stream write operation.
- writev(vectors, cancellable)[source]¶
- Parameters:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.cancellable (
Gio.Cancellable
orNone
) – optional cancellable object
- Raises:
- 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:
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 errorGio.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 returnGio.IOErrorEnum.INVALID_ARGUMENT
if these are exceeded. For example, when writing to a local file on UNIX platforms, the aggregate buffer size must not exceedGObject.G_MAXSSIZE
bytes.New in version 2.60.
- writev_all(vectors, cancellable)[source]¶
- Parameters:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.
- Raises:
- 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:
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 returnsFalse
(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 aroundGio.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:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.io_priority (
int
) – the I/O priority of the requestcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignorecallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
- Raises:
- 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:
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 returnsFalse
(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 aroundGio.OutputStream.writev_async
().New in version 2.60.
- writev_async(vectors, io_priority, cancellable, callback, *user_data)[source]¶
- Parameters:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.io_priority (
int
) – the I/O priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Raises:
- 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:
Finishes a stream writev operation.
New in version 2.60.
- do_close_async(io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optional cancellable objectcallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Returns:
- Return type:
Closes an output stream.
- do_close_fn(cancellable) virtual¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) –- Return type:
- do_flush(cancellable) virtual¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellable object- Returns:
- Return type:
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 errorGio.IOErrorEnum.CANCELLED
will be returned.
- do_flush_async(io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.AsyncResult
.- Returns:
- Return type:
Finishes flushing an output stream.
- do_splice(source, flags, cancellable) virtual¶
- Parameters:
source (
Gio.InputStream
) – aGio.InputStream
.flags (
Gio.OutputStreamSpliceFlags
) – a set ofGio.OutputStreamSpliceFlags
.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
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
GObject.G_MAXSSIZE
, then that will be returned, and there is no way to determine the actual number of bytes spliced.- Return type:
Splices an input stream into an output stream.
- do_splice_async(source, flags, io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
source (
Gio.InputStream
) – aGio.InputStream
.flags (
Gio.OutputStreamSpliceFlags
) – a set ofGio.OutputStreamSpliceFlags
.io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.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:
Finishes an asynchronous stream splice operation.
- do_write_async(buffer, io_priority, cancellable, callback, *user_data) virtual¶
- Parameters:
buffer (
bytes
orNone
) – the buffer containing the data to write.io_priority (
int
) – the io priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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 aGio.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 aGLib.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
) – aGio.AsyncResult
.- Returns:
a #gssize containing the number of bytes written to the stream.
- Return type:
Finishes a stream write operation.
- do_write_fn(buffer, cancellable) virtual¶
- Parameters:
buffer (
bytes
orNone
) – the buffer containing the data to write.cancellable (
Gio.Cancellable
orNone
) – optional cancellable object
- Returns:
Number of bytes written, or -1 on error
- Return type:
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 aGio.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 errorGio.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:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.io_priority (
int
) – the I/O priority of the request.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the request is satisfieduser_data (
object
orNone
) – the data to pass to callback function
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
) – aGio.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:
Finishes a stream writev operation.
New in version 2.60.
- do_writev_fn(vectors, cancellable) virtual¶
- Parameters:
vectors ([
Gio.OutputVector
]) – the buffer containing theGio.OutputVectors
to write.cancellable (
Gio.Cancellable
orNone
) – optional cancellable object
- 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:
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 errorGio.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 returnGio.IOErrorEnum.INVALID_ARGUMENT
if these are exceeded. For example, when writing to a local file on UNIX platforms, the aggregate buffer size must not exceedGObject.G_MAXSSIZE
bytes.New in version 2.60.