Gio.FileIOStream¶
class — extends IOStream, 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 Seekable.tell.
To find out if a file I/O stream supports seeking, use
Seekable.can_seek. To position a file I/O stream, use
Seekable.seek. To find out if a file I/O stream supports
truncating, use Seekable.can_truncate. To truncate a file I/O
stream, use Seekable.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¶
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 io stream for the given attributes.
This function blocks while querying the stream. For the asynchronous
version of this function, see 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
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). I
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[[FileIOStream | 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 FileIOStream.query_info_finish.
For the synchronous version of this function, see
FileIOStream.query_info.
Parameters:
attributes— a file attribute query string.io_priority— the I/O priority of the requestcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallbackto call when the request is satisfied
query_info_finish¶
Finalizes the asynchronous query started
by FileIOStream.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 io stream for the given attributes.
This function blocks while querying the stream. For the asynchronous
version of this function, see 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
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). I
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[[FileIOStream | 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 FileIOStream.query_info_finish.
For the synchronous version of this function, see
FileIOStream.query_info.
Parameters:
attributes— a file attribute query string.io_priority— the I/O priority of the requestcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallbackto call when the request is satisfied
do_query_info_finish¶
Finalizes the asynchronous query started
by FileIOStream.query_info_async.
Parameters:
result— aAsyncResult.
do_seek¶
def do_seek(self, offset: int, type: GLib.SeekType | int, cancellable: Cancellable | None = ...) -> bool