Method

GioFilereplace_readwrite

Declaration

GFileIOStream*
g_file_replace_readwrite (
  GFile* file,
  const char* etag,
  gboolean make_backup,
  GFileCreateFlags flags,
  GCancellable* cancellable,
  GError** error
)

Description

Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn’t exist, it will be created.

For details about the behaviour, see g_file_replace() which does the same thing but returns an output stream only.

Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.

Available since:2.22

Parameters

etag const char*
 

An optional [entity tag][gfile-etag] for the current GFile, or NULL to ignore.

 The argument can be NULL.
 The data is owned by the caller of the function.
 The value is a NUL terminated UTF-8 string.
make_backup gboolean
 

TRUE if a backup should be created.

flags GFileCreateFlags
 

A set of GFileCreateFlags.

cancellable GCancellable
 

Optional GCancellable object, NULL to ignore.

 The argument can be NULL.
 The data is owned by the caller of the function.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: GFileIOStream
 

A GFileIOStream or NULL on error. Free the returned object with g_object_unref().

 The caller of the method takes ownership of the data, and is responsible for freeing it.