diff --git a/gio/ChangeLog b/gio/ChangeLog index 92714959b..02f0ac536 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2007-12-03 Alexander Larsson + + * gfile.[ch]: + * glocalfile.c: + Add G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag + 2007-12-02 A. Walton * gfile.c: diff --git a/gio/gfile.c b/gio/gfile.c index 501cc8c07..7c6f196b3 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -2081,6 +2081,14 @@ g_file_move (GFile *source, } } + if (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE) + { + g_set_error (error, G_IO_ERROR, + G_IO_ERROR_NOT_SUPPORTED, + _("Operation not supported")); + return FALSE; + } + flags |= G_FILE_COPY_ALL_METADATA; if (!g_file_copy (source, destination, flags, cancellable, progress_callback, progress_callback_data, diff --git a/gio/gfile.h b/gio/gfile.h index d5ebcf47a..e9df49dde 100644 --- a/gio/gfile.h +++ b/gio/gfile.h @@ -66,7 +66,8 @@ typedef enum { * @G_FILE_COPY_OVERWRITE: Overwrite any existing files * @G_FILE_COPY_BACKUP: Make a backup of any existing files. TODO: explain backup naming scheme. * @G_FILE_COPY_NOFOLLOW_SYMLINKS: Don't follow symlinks. - * @G_FILE_COPY_ALL_METADATA: Copy all file metadata (see #GFileInfo). + * @G_FILE_COPY_ALL_METADATA: Copy all file metadata instead of just default set (see #GFileInfo). + * @G_FILE_COPY_NO_FALLBACK_FOR_MOVE: Don't use copy and delete fallback if native move not supported. * * Flags used when copying or moving files. */ @@ -75,7 +76,8 @@ typedef enum { G_FILE_COPY_OVERWRITE = (1<<0), G_FILE_COPY_BACKUP = (1<<1), G_FILE_COPY_NOFOLLOW_SYMLINKS = (1<<2), - G_FILE_COPY_ALL_METADATA = (1<<3) + G_FILE_COPY_ALL_METADATA = (1<<3), + G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1<<4) } GFileCopyFlags; /** diff --git a/gio/glocalfile.c b/gio/glocalfile.c index a3eb9662e..22ccc10ad 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -1746,10 +1746,13 @@ g_local_file_move (GFile *source, if (rename (local_source->filename, local_destination->filename) == -1) { int errsv = errno; - if (errsv == EXDEV) - goto fallback; - if (errsv == EINVAL) + if (errsv == EXDEV) + /* This will cause the fallback code to run */ + g_set_error (error, G_IO_ERROR, + G_IO_ERROR_NOT_SUPPORTED, + _("Move between mounts not supported")); + else if (errsv == EINVAL) /* This must be an invalid filename, on e.g. FAT, or we're trying to move the file into itself... We return invalid filename for both... */ @@ -1765,18 +1768,8 @@ g_local_file_move (GFile *source, } return TRUE; - - fallback: - - if (!g_file_copy (source, destination, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA, cancellable, - progress_callback, progress_callback_data, - error)) - return FALSE; - - return g_file_delete (source, cancellable, error); } - static GDirectoryMonitor* g_local_file_monitor_dir (GFile *file, GFileMonitorFlags flags,