glibmm: Gio::FileOutputStream Class Reference

# Gio::FileOutputStream Class Reference
[Stream Classes]

FileOutputStream provides output streams that write their content to a file. More...

`#include <giomm/fileoutputstream.h>`

Inheritance diagram for Gio::FileOutputStream:
[legend]

List of all members.

## Public Member Functions

virtual | ~FileOutputStream ()
GFileOutputStream* | gobj ()
| Provides access to the underlying C GObject.
const GFileOutputStream* | gobj () const
| Provides access to the underlying C GObject.
GFileOutputStream* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::RefPtr< FileInfo > | query_info (const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*")
| Queries a file output stream for the given attributes .
Glib::RefPtr< FileInfo > | query_info (const std::string& attributes="*")
| Queries a file output stream for the given attributes .
void | query_info_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const std::string& attributes="*", int io_priority=Glib::PRIORITY_DEFAULT)
| Queries the stream information asynchronously.
void | query_info_async (const SlotAsyncReady& slot, const std::string& attributes="*", int io_priority=Glib::PRIORITY_DEFAULT)
| Queries the stream information asynchronously.
Glib::RefPtr< FileInfo > | query_info_finish (const Glib::RefPtr< AsyncResult >& result)
| Finalizes the asynchronous query started by g_file_output_stream_query_info_async().
std::string | get_etag () const
| Gets the entity tag for the file when it has been written.

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr < Gio::FileOutputStream > | wrap (GFileOutputStream* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

FileOutputStream provides output streams that write their content to a file.

FileOutputStream implements Seekable, which allows the output stream to jump to arbitrary positions in the file and to truncate the file, provided the file system of the file supports these operations. Use the methods of the Seekable base class for seeking and positioning.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::FileOutputStream::~FileOutputStream | ( |  | ) | `[virtual]`

## Member Function Documentation

std::string Gio::FileOutputStream::get_etag | ( |  | ) | const

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.

Returns:
  The entity tag for the stream.

const GFileOutputStream* Gio::FileOutputStream::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::OutputStream.

GFileOutputStream* Gio::FileOutputStream::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::OutputStream.

GFileOutputStream* Gio::FileOutputStream::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gio::OutputStream.

Glib::RefPtr<FileInfo> Gio::FileOutputStream::query_info | ( | const std::string & | attributes = `"*"` | ) |

Queries a file output stream for the given attributes .

This function blocks while querying the stream. For the asynchronous version of this function, see query_info_async(). While the stream is blocked, the stream will set the pending flag internally, and any other operations on the stream will throw a Gio::Error with PENDING.

Can fail if the stream was already closed (with a CLOSED error), the stream has pending operations (with an PENDING error), or if querying info is not supported for the stream's interface (with a NOT_SUPPORTED error). In all cases of failure, an empty RefPtr will be returned.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED may be thrown, and an empty RefPtr will be returned.

Parameters:

  | cancellable | A Cancellable object.
  | attributes | A file attribute query string.

Returns:
  A FileInfo for the stream, or an empty RefPtr on error.

Glib::RefPtr<FileInfo> Gio::FileOutputStream::query_info | ( | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"` |
| ) |  |  |

Queries a file output stream for the given attributes .

This function blocks while querying the stream. For the asynchronous version of this function, see query_info_async(). While the stream is blocked, the stream will set the pending flag internally, and any other operations on the stream will throw a Gio::Error with PENDING.

Can fail if the stream was already closed (with a CLOSED error), the stream has pending operations (with a PENDING error), or if querying info is not supported for the stream's interface (with a NOT_SUPPORTED error). In all cases of failure, an empty RefPtr will be returned.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED may be thrown, and an empty RefPtr will be returned.

Parameters:

  | cancellable | A Cancellable object.
  | attributes | A file attribute query string.

Returns:
  A FileInfo for the stream, or an empty RefPtr on error.

void Gio::FileOutputStream::query_info_async | ( | const SlotAsyncReady & | slot,
|  | const std::string & | attributes = `"*"`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT` |
| ) |  |  |

Queries the stream information asynchronously.

When the operation is finished slot will be called. You can then call query_info_finish() to get the result of the operation.

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

Parameters:

  | slot | Callback to call when the request is satisfied.
  | attributes | A file attribute query string.
  | io_priority | The <io-priority of the request.

void Gio::FileOutputStream::query_info_async | ( | const SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const std::string & | attributes = `"*"`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT` |
| ) |  |  |

Queries the stream information asynchronously.

When the operation is finished slot will be called. You can then call query_info_finish() to get the result of the operation.

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

If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error with CANCELLED may be thrown

Parameters:

  | slot | Callback to call when the request is satisfied.
  | cancellable | A Cancellable object.
  | attributes | A file attribute query string.
  | io_priority | The <io-priority of the request.

Glib::RefPtr<FileInfo> Gio::FileOutputStream::query_info_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finalizes the asynchronous query started by g_file_output_stream_query_info_async().

Parameters:

  | result | A AsyncResult.

Returns:
  A FileInfo for the finished query.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::FileOutputStream > wrap | ( | GFileOutputStream * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.