:right-sidebar: True FileIOStream =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.22 .. class:: FileIOStream(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gio.IOStream`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.Seekable` ``GFileIOStream`` provides I/O streams that both read and write to the same file handle. ``GFileIOStream`` implements :obj:`~gi.repository.Gio.Seekable`, which allows the I/O 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 I/O stream, use :obj:`~gi.repository.Gio.Seekable.tell`. To find out if a file I/O stream supports seeking, use :obj:`~gi.repository.Gio.Seekable.can_seek`. To position a file I/O stream, use :obj:`~gi.repository.Gio.Seekable.seek`. To find out if a file I/O stream supports truncating, use :obj:`~gi.repository.Gio.Seekable.can_truncate`. To truncate a file I/O stream, use :obj:`~gi.repository.Gio.Seekable.truncate`. The default implementation of all the ``GFileIOStream`` operations and the implementation of :obj:`~gi.repository.Gio.Seekable` just call into the same operations on the output stream. Methods ------- .. rst-class:: interim-class .. class:: FileIOStream :no-index: .. method:: do_can_seek(self) -> bool .. method:: do_can_truncate(self) -> bool .. method:: do_get_etag(self) -> str | None .. method:: do_query_info(self, attributes: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo :param attributes: :param cancellable: .. method:: do_query_info_async(self, attributes: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None :param attributes: :param io_priority: :param cancellable: :param callback: :param user_data: .. method:: do_query_info_finish(self, result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo :param result: .. method:: do_seek() .. method:: do_tell(self) -> int .. method:: do_truncate_fn(self, size: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool :param size: :param cancellable: .. method:: get_etag() -> str | None 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. .. versionadded:: 2.22 .. method:: query_info(attributes: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Queries a file io stream for the given ``attributes``. This function blocks while querying the stream. For the asynchronous version of this function, see :func:`~gi.repository.Gio.FileIOStream.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 :const:`~gi.repository.Gio.IOErrorEnum.PENDING`. Can fail if the stream was already closed (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`), the stream has pending operations (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.PENDING`), or if querying info is not supported for the stream's interface (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED`). I all cases of failure, :const:`None` will be returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be set, and :const:`None` will be returned. .. versionadded:: 2.22 :param attributes: a file attribute query string. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. .. method:: query_info_async(attributes: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously queries the ``stream`` for a :obj:`~gi.repository.Gio.FileInfo`. When completed, ``callback`` will be called with a :obj:`~gi.repository.Gio.AsyncResult` which can be used to finish the operation with :func:`~gi.repository.Gio.FileIOStream.query_info_finish`. For the synchronous version of this function, see :func:`~gi.repository.Gio.FileIOStream.query_info`. .. versionadded:: 2.22 :param attributes: a file attribute query string. :param io_priority: the `I/O priority `_ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: query_info_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finalizes the asynchronous query started by :func:`~gi.repository.Gio.FileIOStream.query_info_async`. .. versionadded:: 2.22 :param result: a :obj:`~gi.repository.Gio.AsyncResult`. Virtual Methods --------------- .. rst-class:: interim-class .. class:: FileIOStream :no-index: .. method:: do_can_seek(type, self) -> bool :param type: :param self: .. method:: do_can_truncate(type, self) -> bool :param type: :param self: .. method:: do_get_etag(type, self) -> str | None 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. .. versionadded:: 2.22 :param type: :param self: .. method:: do_query_info(type, self, attributes: str, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.FileInfo Queries a file io stream for the given ``attributes``. This function blocks while querying the stream. For the asynchronous version of this function, see :func:`~gi.repository.Gio.FileIOStream.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 :const:`~gi.repository.Gio.IOErrorEnum.PENDING`. Can fail if the stream was already closed (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.CLOSED`), the stream has pending operations (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.PENDING`), or if querying info is not supported for the stream's interface (with ``error`` being set to :const:`~gi.repository.Gio.IOErrorEnum.NOT_SUPPORTED`). I all cases of failure, :const:`None` will be returned. If ``cancellable`` is not :const:`None`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error :const:`~gi.repository.Gio.IOErrorEnum.CANCELLED` will be set, and :const:`None` will be returned. .. versionadded:: 2.22 :param type: :param self: :param attributes: a file attribute query string. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. .. method:: do_query_info_async(type, self, attributes: str, io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously queries the ``stream`` for a :obj:`~gi.repository.Gio.FileInfo`. When completed, ``callback`` will be called with a :obj:`~gi.repository.Gio.AsyncResult` which can be used to finish the operation with :func:`~gi.repository.Gio.FileIOStream.query_info_finish`. For the synchronous version of this function, see :func:`~gi.repository.Gio.FileIOStream.query_info`. .. versionadded:: 2.22 :param type: :param self: :param attributes: a file attribute query string. :param io_priority: the `I/O priority `_ of the request :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: do_query_info_finish(type, self, result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.FileInfo Finalizes the asynchronous query started by :func:`~gi.repository.Gio.FileIOStream.query_info_async`. .. versionadded:: 2.22 :param type: :param self: :param result: a :obj:`~gi.repository.Gio.AsyncResult`. .. method:: do_seek() .. method:: do_tell(type, self) -> int :param type: :param self: .. method:: do_truncate_fn(type, self, size: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> bool The type of the None singleton. :param type: :param self: :param size: :param cancellable: Fields ------ .. rst-class:: interim-class .. class:: FileIOStream :no-index: .. attribute:: parent_instance .. attribute:: priv