Gio.File.prototype.replace_contents_async

function replace_contents_async(contents: ByteArray, etag: String, make_backup: Boolean, flags: Gio.FileCreateFlags, cancellable: Gio.Cancellable, callback: Gio.AsyncReadyCallback): void {
    // Gjs wrapper for g_file_replace_contents_async()
}
  

Starts an asynchronous replacement of file with the given contents of length bytes. etag will replace the document's current entity tag.

When this operation has completed, callback will be called with @user_user data, and the operation can be finalized with Gio.File.prototype.replace_contents_finish.

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.

If make_backup is true, this function will attempt to make a backup of file.

Note that no copy of @content will be made, so it must stay valid until callback is called. See Gio.File.prototype.replace_contents_bytes_async for a GLib.Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

contents

string of contents to replace the file with

etag

a new [entity tag][gfile-etag] for the file, 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

callback

a Gio.AsyncReadyCallback to call when the request is satisfied