Method

GioFilereplace_readwrite

since: 2.22

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

Type: 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

Type: gboolean

TRUE if a backup should be created.

flags

Type: GFileCreateFlags

A set of GFileCreateFlags.

cancellable

Type: GCancellable

Optional GCancellable object, NULL to ignore.

The argument can be NULL.
The data is owned by the caller of the function.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: 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.