Gio.File.prototype.replace_readwrite

function replace_readwrite(etag: String, make_backup: Boolean, flags: Gio.FileCreateFlags, cancellable: Gio.Cancellable): Gio.FileIOStream {
    // Gjs wrapper for g_file_replace_readwrite()
}
  

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 Gio.File.prototype.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.

Since 2.22

etag

an optional [entity tag][gfile-etag] for the current Gio.File, or #NULL to ignore

make_backup

true if a backup should be created

flags

a set of Gio.FileCreateFlags

cancellable

optional Gio.Cancellable object, null to ignore

Returns

a Gio.FileIOStream or null on error. Free the returned object with GObject.Object.prototype.unref.