Method

GioFilemove

Declaration

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

Description

Tries to move the file or directory source to the location specified by destination. If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.

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

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 may be returned (if the native move operation isn’t available).

Parameters

destination GFile
 

GFile pointing to the destination location.

 The data is owned by the caller of the function.
flags GFileCopyFlags
 

Set of GFileCopyFlags.

cancellable GCancellable
 

Optional GCancellable object, NULL to ignore.

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

GFileProgressCallback function for updates.

 The argument can be NULL.
progress_callback_data gpointer
 

Gpointer to user data for the callback function.

 The argument can be NULL.
 The data is owned by the caller of the function.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: gboolean
 

TRUE on successful move, FALSE otherwise.