Gio.FileOutputStream¶
class — extends OutputStream, Seekable
GFileOutputStream provides output streams that write their
content to a file.
GFileOutputStream implements Seekable, which allows the output
stream to jump to arbitrary positions in the file and to truncate
the file, provided the filesystem of the file supports these
operations.
To find the position of a file output stream, use Seekable.tell.
To find out if a file output stream supports seeking, use
Seekable.can_seek.To position a file output stream, use
Seekable.seek. To find out if a file output stream supports
truncating, use Seekable.can_truncate. To truncate a file output
stream, use Seekable.truncate.
Methods¶
get_etag¶
Gets the entity tag for the file when it has been written. This must be called after the stream has been written and closed, as the etag can change while writing.
query_info¶
Queries a file output stream for the given attributes.
This function blocks while querying the stream. For the asynchronous
version of this function, see FileOutputStream.query_info_async.
While the stream is blocked, the stream will set the pending flag
internally, and any other operations on the stream will fail with
IOErrorEnum.PENDING.
Can fail if the stream was already closed (with error being set to
IOErrorEnum.CLOSED), the stream has pending operations (with error being
set to IOErrorEnum.PENDING), or if querying info is not supported for
the stream's interface (with error being set to IOErrorEnum.NOT_SUPPORTED). In
all cases of failure, None will be returned.
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 IOErrorEnum.CANCELLED will be set, and None will
be returned.
Parameters:
attributes— a file attribute query string.cancellable— optionalCancellableobject,Noneto ignore.
query_info_async¶
def query_info_async(self, attributes: str, io_priority: int, cancellable: Cancellable | None = ..., callback: Callable[[FileOutputStream | None, AsyncResult], None] | None = ...) -> None
Asynchronously queries the stream for a FileInfo. When completed,
callback will be called with a AsyncResult which can be used to
finish the operation with FileOutputStream.query_info_finish.
For the synchronous version of this function, see
FileOutputStream.query_info.
Parameters:
attributes— a file attribute query string.io_priority— the I/O priority of the requestcancellable— optionalCancellableobject,Noneto ignore.callback— callback to call when the request is satisfied
query_info_finish¶
Finalizes the asynchronous query started
by FileOutputStream.query_info_async.
Parameters:
result— aAsyncResult.
Virtual methods¶
do_can_seek¶
do_can_truncate¶
do_get_etag¶
Gets the entity tag for the file when it has been written. This must be called after the stream has been written and closed, as the etag can change while writing.
do_query_info¶
Queries a file output stream for the given attributes.
This function blocks while querying the stream. For the asynchronous
version of this function, see FileOutputStream.query_info_async.
While the stream is blocked, the stream will set the pending flag
internally, and any other operations on the stream will fail with
IOErrorEnum.PENDING.
Can fail if the stream was already closed (with error being set to
IOErrorEnum.CLOSED), the stream has pending operations (with error being
set to IOErrorEnum.PENDING), or if querying info is not supported for
the stream's interface (with error being set to IOErrorEnum.NOT_SUPPORTED). In
all cases of failure, None will be returned.
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 IOErrorEnum.CANCELLED will be set, and None will
be returned.
Parameters:
attributes— a file attribute query string.cancellable— optionalCancellableobject,Noneto ignore.
do_query_info_async¶
def do_query_info_async(self, attributes: str, io_priority: int, cancellable: Cancellable | None = ..., callback: Callable[[FileOutputStream | None, AsyncResult], None] | None = ...) -> None
Asynchronously queries the stream for a FileInfo. When completed,
callback will be called with a AsyncResult which can be used to
finish the operation with FileOutputStream.query_info_finish.
For the synchronous version of this function, see
FileOutputStream.query_info.
Parameters:
attributes— a file attribute query string.io_priority— the I/O priority of the requestcancellable— optionalCancellableobject,Noneto ignore.callback— callback to call when the request is satisfied
do_query_info_finish¶
Finalizes the asynchronous query started
by FileOutputStream.query_info_async.
Parameters:
result— aAsyncResult.
do_seek¶
def do_seek(self, offset: int, type: GLib.SeekType | int, cancellable: Cancellable | None = ...) -> bool