## GFileIOStream

GFileIOStream — File read and write streaming operations

## Synopsis

    #include <gio/gio.h>

                        GFileIOStream;
    char *              g_file_io_stream_get_etag           (GFileIOStream *stream);
    GFileInfo *         g_file_io_stream_query_info         (GFileIOStream *stream,
                                                             const char *attributes,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                g_file_io_stream_query_info_async   (GFileIOStream *stream,
                                                             const char *attributes,
                                                             int io_priority,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GFileInfo *         g_file_io_stream_query_info_finish  (GFileIOStream *stream,
                                                             GAsyncResult *result,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----GIOStream
             +----GFileIOStream

## Implemented Interfaces

GFileIOStream implements GSeekable.

## Description

GFileIOStream provides io streams that both read and write to the same file handle.

GFileIOStream implements GSeekable, which allows the io 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 io stream, use `g_seekable_tell()`.

To find out if a file io stream supports seeking, use `g_seekable_can_seek()`. To position a file io stream, use `g_seekable_seek()`. To find out if a file io stream supports truncating, use `g_seekable_can_truncate()`. To truncate a file io stream, use `g_seekable_truncate()`.

The default implementation of all the GFileIOStream operations and the implementation of GSeekable just call into the same operations on the output stream.

## Details

### GFileIOStream

    typedef struct _GFileIOStream GFileIOStream;

A subclass of GIOStream for opened files. This adds a few file-specific operations and seeking and truncating.

GFileIOStream implements GSeekable.

### g_file_io_stream_get_etag ()

    char *              g_file_io_stream_get_etag           (GFileIOStream *stream);

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.

`stream` : | a GFileIOStream.
Returns : | the entity tag for the stream.

Since 2.22

### g_file_io_stream_query_info ()

    GFileInfo *         g_file_io_stream_query_info         (GFileIOStream *stream,
                                                             const char *attributes,
                                                             GCancellable *cancellable,
                                                             GError **error);

Queries a file io stream for the given `attributes`. This function blocks while querying the stream. For the asynchronous version of this function, see `g_file_io_stream_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 `G_IO_ERROR_PENDING`.

Can fail if the stream was already closed (with `error` being set to `G_IO_ERROR_CLOSED`), the stream has pending operations (with `error` being set to `G_IO_ERROR_PENDING`), or if querying info is not supported for the stream's interface (with `error` being set to `G_IO_ERROR_NOT_SUPPORTED`). I all cases of failure, `NULL` will be returned.

If `cancellable` is not `NULL`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error `G_IO_ERROR_CANCELLED` will be set, and `NULL` will be returned.

`stream` : | a GFileIOStream.
`attributes` : | a file attribute query string.
`cancellable` : | optional GCancellable object, `NULL` to ignore.
`error` : | a GError, `NULL` to ignore.
Returns : | a GFileInfo for the `stream`, or `NULL` on error.

Since 2.22

### g_file_io_stream_query_info_async ()

    void                g_file_io_stream_query_info_async   (GFileIOStream *stream,
                                                             const char *attributes,
                                                             int io_priority,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Asynchronously queries the `stream` for a GFileInfo. When completed, `callback` will be called with a GAsyncResult which can be used to finish the operation with `g_file_io_stream_query_info_finish()`.

For the synchronous version of this function, see `g_file_io_stream_query_info()`.

`stream` : | a GFileIOStream.
`attributes` : | a file attribute query string.
`io_priority` : | the I/O priority of the request.
`cancellable` : | optional GCancellable object, `NULL` to ignore.
`callback` : | callback to call when the request is satisfied
`user_data` : | the data to pass to callback function

Since 2.22

### g_file_io_stream_query_info_finish ()

    GFileInfo *         g_file_io_stream_query_info_finish  (GFileIOStream *stream,
                                                             GAsyncResult *result,
                                                             GError **error);

Finalizes the asynchronous query started by `g_file_io_stream_query_info_async()`.

`stream` : | a GFileIOStream.
`result` : | a GAsyncResult.
`error` : | a GError, `NULL` to ignore.
Returns : | A GFileInfo for the finished query.

Since 2.22

## See Also

GIOStream, GFileInputStream, GFileOutputStream, GSeekable