mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
Add G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag
2007-12-03 Alexander Larsson <alexl@redhat.com> * gfile.[ch]: * glocalfile.c: Add G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag svn path=/trunk/; revision=6015
This commit is contained in:
parent
6f605509fd
commit
6394ae6fdb
@ -1,3 +1,9 @@
|
||||
2007-12-03 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gfile.[ch]:
|
||||
* glocalfile.c:
|
||||
Add G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag
|
||||
|
||||
2007-12-02 A. Walton <awalton@svn.gnome.org>
|
||||
|
||||
* 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,
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user