### Virtual Method

# Gio File copy

#### Declaration

    gboolean
    copy (
      GFile* source,
      GFile* destination,
      GFileCopyFlags flags,
      GCancellable* cancellable,
      GFileProgressCallback progress_callback,
      gpointer progress_callback_data,
      GError** error
    )

#### Description

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 the flag `G_FILE_COPY_ALL_METADATA` is specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, see `GFileInfo`).

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 `G_IO_ERROR_CANCELLED` will be returned.

If `progress_callback` is not `NULL`, then the operation can be monitored by setting this to a `GFileProgressCallback` 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 `G_IO_ERROR_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 `G_IO_ERROR_EXISTS` is returned.

If trying to overwrite a file over a directory, the `G_IO_ERROR_IS_DIRECTORY` error is returned. If trying to overwrite a directory with a directory the `G_IO_ERROR_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 `G_IO_ERROR_WOULD_RECURSE` error is returned.

If you are interested in copying the `GFile` object itself (not the on-disk file), see g_file_dup().

#### Parameters

`destination`

  Type: `GFile`

  Destination `GFile`.

  The data is owned by the caller of the function.

`flags`

  Type: `GFileCopyFlags`

  Set of `GFileCopyFlags`.

`cancellable`

  Type: `GCancellable`

  Optional `GCancellable` object, `NULL` to ignore.

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

`progress_callback`

  Type: `GFileProgressCallback`

  Function to callback with progress information, or `NULL` if progress information is not needed.

`progress_callback_data`

  Type: `gpointer`

  User data to pass to `progress_callback`.

  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 be left initialized to `NULL` by the virtual function 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: `gboolean`

`TRUE` on success, `FALSE` otherwise.