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
- 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
error
being set toCLOSED
), the stream has pending operations (witherror
being set toPENDING
), or if querying info is not supported for the stream’s interface (witherror
being set toNOT_SUPPORTED
). I all cases of failure,None
will be returned.If
cancellable
is notNone
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorCANCELLED
will be set, andNone
will be returned.Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
cancellable – optional
Cancellable
object,None
to ignore.
- query_info_async(attributes: str, io_priority: int, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Asynchronously queries the
stream
for aFileInfo
. When completed,callback
will be called with aAsyncResult
which 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
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
to 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
error
being set toCLOSED
), the stream has pending operations (witherror
being set toPENDING
), or if querying info is not supported for the stream’s interface (witherror
being set toNOT_SUPPORTED
). I all cases of failure,None
will be returned.If
cancellable
is notNone
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorCANCELLED
will be set, andNone
will be returned.Added in version 2.22.
- Parameters:
attributes – a file attribute query string.
cancellable – optional
Cancellable
object,None
to ignore.
- do_query_info_async(attributes: str, io_priority: int, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Asynchronously queries the
stream
for aFileInfo
. When completed,callback
will be called with aAsyncResult
which 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
Cancellable
object,None
to ignore.callback – a
AsyncReadyCallback
to 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
- Parameters:
size
cancellable