Gio.File.prototype.replace_contents
function replace_contents(contents: ByteArray, etag: String, make_backup: Boolean, flags: Gio.FileCreateFlags, cancellable: Gio.Cancellable): [ok: Boolean, new_etag: String] { // Gjs wrapper for g_file_replace_contents() }
Replaces the contents of file with contents of length bytes.
If etag is specified (not null), any existing file must have that etag, or the error Gio.IOErrorEnum.wrong_etag will be returned.
If make_backup is true, this function will attempt to make a backup of file.
If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error Gio.IOErrorEnum.cancelled will be returned.
The returned new_etag can be used to verify that the file hasn't changed the next time it is saved over.
- contents
a string containing the new contents for file
- etag
the old [entity-tag][gfile-etag] for the document, or null
- make_backup
true if a backup should be created
- flags
a set of Gio.FileCreateFlags
- cancellable
optional Gio.Cancellable object, null to ignore
- ok
true if successful. If an error has occurred, this function will return false and set @error appropriately if present.
- new_etag
a location to a new [entity tag][gfile-etag] for the document. This should be freed with GLib.free when no longer needed, or null