Gio.File.prototype.copy

function copy(destination: Gio.File, flags: Gio.FileCopyFlags, cancellable: Gio.Cancellable, progress_callback: Gio.FileProgressCallback): Boolean {
    // Gjs wrapper for g_file_copy()
}
  

Copies the file source to the location specified by destination. Can not handle recursive copies of directories.

If the flag #G_FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.

If the flag #G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.

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 progress_callback is not null, then the operation can be monitored by setting this to a Gio.FileProgressCallback function. progress_callback_data will be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.

If the source file does not exist, then the Gio.IOErrorEnum.not_found error is returned, independent on the status of the destination.

If #G_FILE_COPY_OVERWRITE is not specified and the target exists, then the error Gio.IOErrorEnum.exists is returned.

If trying to overwrite a file over a directory, the Gio.IOErrorEnum.is_directory error is returned. If trying to overwrite a directory with a directory the Gio.IOErrorEnum.would_merge error is returned.

If the source is a directory and the target does not exist, or #G_FILE_COPY_OVERWRITE is specified and the target is a file, then the Gio.IOErrorEnum.would_recurse error is returned.

If you are interested in copying the Gio.File object itself (not the on-disk file), see Gio.File.prototype.dup.

destination

destination Gio.File

flags

set of Gio.FileCopyFlags

cancellable

optional Gio.Cancellable object, null to ignore

progress_callback

function to callback with progress information, or null if progress information is not needed

Returns

true on success, false otherwise.