FileIOStream#
Added in version 2.22.
Superclasses: IOStream, Object
Implemented Interfaces: Seekable
GFileIOStream provides I/O streams that both read and write to the same
file handle.
GFileIOStream implements 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 tell.
To find out if a file I/O stream supports seeking, use
can_seek. To position a file I/O stream, use
seek. To find out if a file I/O stream supports
truncating, use can_truncate. To truncate a file I/O
stream, use truncate.
The default implementation of all the GFileIOStream operations
and the implementation of Seekable just call into the same
operations on the output stream.
Methods#
- class FileIOStream
-
- do_query_info(self, attributes: str, cancellable: Cancellable | None = None) FileInfo#
- Parameters:
attributes
cancellable
- do_query_info_async(self, attributes: str, io_priority: int, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
- Parameters:
attributes
io_priority
cancellable
callback
user_data
- do_query_info_finish(self, result: AsyncResult) FileInfo#
- Parameters:
result
- do_seek(self, offset: int, type: SeekType, cancellable: Cancellable | None = None) bool#
- Parameters:
offset
type
cancellable
- do_truncate_fn(self, size: int, cancellable: Cancellable | None = None) bool#
- Parameters:
size
cancellable
- 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.
Added in version 2.22.
- query_info(attributes: str, cancellable: Cancellable | None = None) FileInfo#
Queries a file io stream for the given
attributes. This function blocks while querying the stream. For the asynchronous version of this function, seequery_info_async(). While the stream is blocked, the stream will set the pending flag internally, and any other operations on the stream will fail withPENDING.Can fail if the stream was already closed (with
errorbeing set toCLOSED), the stream has pending operations (witherrorbeing set toPENDING), or if querying info is not supported for the stream’s interface (witherrorbeing set toNOT_SUPPORTED). I all cases of failure,Nonewill be returned.If
cancellableis notNone, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorCANCELLEDwill be set, andNonewill be returned.Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
cancellable – optional
Cancellableobject,Noneto ignore.
- async query_info_async(self, attributes: str, io_priority: int) FileInfo#
This is the awaitable version of
query_info_async().Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
io_priority – the I/O priority of the request
- query_info_async(attributes: str, io_priority: int, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously queries the
streamfor aFileInfo. When completed,callbackwill be called with aAsyncResultwhich can be used to finish the operation withquery_info_finish().For the synchronous version of this function, see
query_info().Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
io_priority – the I/O priority of the request
cancellable – optional
Cancellableobject,Noneto ignore.callback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- query_info_finish(result: AsyncResult) FileInfo#
Finalizes the asynchronous query started by
query_info_async().Added in version 2.22.
- Parameters:
result – a
AsyncResult.
Virtual Methods#
- class FileIOStream
-
- do_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.
Added in version 2.22.
- do_query_info(attributes: str, cancellable: Cancellable | None = None) FileInfo#
Queries a file io stream for the given
attributes. This function blocks while querying the stream. For the asynchronous version of this function, seequery_info_async(). While the stream is blocked, the stream will set the pending flag internally, and any other operations on the stream will fail withPENDING.Can fail if the stream was already closed (with
errorbeing set toCLOSED), the stream has pending operations (witherrorbeing set toPENDING), or if querying info is not supported for the stream’s interface (witherrorbeing set toNOT_SUPPORTED). I all cases of failure,Nonewill be returned.If
cancellableis notNone, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorCANCELLEDwill be set, andNonewill be returned.Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
cancellable – optional
Cancellableobject,Noneto ignore.
- do_query_info_async(attributes: str, io_priority: int, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Asynchronously queries the
streamfor aFileInfo. When completed,callbackwill be called with aAsyncResultwhich can be used to finish the operation withquery_info_finish().For the synchronous version of this function, see
query_info().Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
io_priority – the I/O priority of the request
cancellable – optional
Cancellableobject,Noneto ignore.callback – a
AsyncReadyCallbackto call when the request is satisfieduser_data – the data to pass to callback function
- do_query_info_finish(result: AsyncResult) FileInfo#
Finalizes the asynchronous query started by
query_info_async().Added in version 2.22.
- Parameters:
result – a
AsyncResult.
- do_seek(offset: int, type: SeekType, cancellable: Cancellable | None = None) bool#
- Parameters:
offset
type
cancellable
- do_truncate_fn(size: int, cancellable: Cancellable | None = None) bool#
The type of the None singleton.
- Parameters:
size
cancellable