Add G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag
authorAlexander Larsson <alexl@redhat.com>
Mon, 3 Dec 2007 09:11:48 +0000 (09:11 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 3 Dec 2007 09:11:48 +0000 (09:11 +0000)
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

gio/ChangeLog
gio/gfile.c
gio/gfile.h
gio/glocalfile.c

index 9271495..02f0ac5 100644 (file)
@@ -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:
index 501cc8c..7c6f196 100644 (file)
@@ -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,
index d5ebcf4..e9df49d 100644 (file)
@@ -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;
 
 /**
index a3eb966..22ccc10 100644 (file)
@@ -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,