logo top
Main Page   Widgets   glibmm Namespaces   Book  

Gio::FileOutputStream Class Reference

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

Inheritance diagram for Gio::FileOutputStream:

Inheritance graph
[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<FileInfoquery_info (const std::string& attributes, const Glib::RefPtr<Cancellable>& cancellable)
 Queries a file output stream for the given attributes .
void query_info_async (const std::string& attributes, int io_priority, Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
Glib::RefPtr<FileInfoquery_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 its been written.
goffset tell () const
 Gets the current location within the stream.
bool can_seek () const
 Checks if the stream can be seeked.
bool seek (goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable)
 Seeks to a location in a file output stream.
bool can_truncate () const
 Checks if the stream can be truncated.
bool truncate (goffset size, const Glib::RefPtr<Cancellable>& cancellable)
 Truncates a file output stream.

Related Functions

(Note that these are not member functions.)

Glib::RefPtr<Gio::FileOutputStreamwrap (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 filesystem of the file supports these operations. In addition to the generic Seekable API, FileOutputStream has its own API for seeking and positioning. To find the position of a file output stream, use stream_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().

Since glibmm 2.16:


Constructor & Destructor Documentation

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


Member Function Documentation

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

Provides access to the underlying C GObject.

Reimplemented from Gio::OutputStream.

const GFileOutputStream* Gio::FileOutputStream::gobj (  )  const [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,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Queries a file output stream for the given attributes .

This function blocks while querying the stream. For the asynchronous version of this function, see g_file_output_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). In all cases of failure, 0 will be returned.

If cancellable is not 0, 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 0 will be returned.

Parameters:
attributes A file attribute query string.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, 0 to ignore.
Returns:
A G::FileInfo for the stream , or 0 on error.

void Gio::FileOutputStream::query_info_async ( const std::string attributes,
int  io_priority,
Glib::RefPtr<Cancellable>&  cancellable,
const SlotAsyncReady slot 
)

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 G::AsyncResult.
error A G::Error, 0 to ignore.
Returns:
A G::FileInfo for the finished query.

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

Gets the entity tag for the file when its 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.

goffset Gio::FileOutputStream::tell (  )  const

Gets the current location within the stream.

Returns:
A goffset of the location within the stream.

bool Gio::FileOutputStream::can_seek (  )  const

Checks if the stream can be seeked.

Returns:
true if seeking is supported by the stream.

bool Gio::FileOutputStream::seek ( goffset  offset,
Glib::SeekType  type,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Seeks to a location in a file output stream.

Parameters:
offset A goffset to seek.
type A G::SeekType.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, 0 to ignore.
Returns:
true if the seek was successful. false otherwise.

bool Gio::FileOutputStream::can_truncate (  )  const

Checks if the stream can be truncated.

Returns:
true if stream can be truncated.

bool Gio::FileOutputStream::truncate ( goffset  size,
const Glib::RefPtr<Cancellable>&  cancellable 
)

Truncates a file output stream.

Parameters:
size A goffset to truncate the stream at.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error, 0 to ignore.
Returns:
true if stream is truncated successfully.


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.


The documentation for this class was generated from the following file:

Generated for glibmm 2.4 by Doxygen 1.5.1 © 1997-2001