FileOutputStream#
Superclasses: OutputStream
, Object
Implemented Interfaces: 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 tell
.
To find out if a file output stream supports seeking, use
can_seek
.To position a file output stream, use
seek
. To find out if a file output stream supports
truncating, use can_truncate
. To truncate a file output
stream, use truncate
.
Methods#
- class FileOutputStream
- 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.
- query_info(attributes: str, cancellable: Cancellable | None = None) FileInfo #
Queries a file output 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
). In 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.- 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()
.- Parameters:
attributes – a file attribute query string.
io_priority – the I/O priority of the request
cancellable – optional
Cancellable
object,None
to ignore.callback – callback to call when the request is satisfied
user_data – the data to pass to callback function
- query_info_finish(result: AsyncResult) FileInfo #
Finalizes the asynchronous query started by
query_info_async()
.- Parameters:
result – a
AsyncResult
.
Virtual Methods#
- class FileOutputStream
-
- 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.
- do_query_info(attributes: str, cancellable: Cancellable | None = None) FileInfo #
Queries a file output 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
). In 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.- 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()
.- Parameters:
attributes – a file attribute query string.
io_priority –
the I/O priority of the request
cancellable – optional
Cancellable
object,None
to ignore.callback – callback to call when the request is satisfied
user_data – the data to pass to callback function
- do_query_info_finish(result: AsyncResult) FileInfo #
Finalizes the asynchronous query started by
query_info_async()
.- 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