Index: programs/gnomevfs-mv.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/programs/gnomevfs-mv.c,v
retrieving revision 1.2
diff -u -p -r1.2 gnomevfs-mv.c
--- programs/gnomevfs-mv.c	5 Jun 2005 17:35:12 -0000	1.2
+++ programs/gnomevfs-mv.c	23 Aug 2005 10:38:02 -0000
@@ -23,6 +23,7 @@
 */
 
 #include <libgnomevfs/gnome-vfs.h>
+#include <libgnomevfs/gnome-vfs-file-info.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -43,7 +44,10 @@ int
 main (int argc, char **argv)
 {
 	GnomeVFSResult    result;
+	GnomeVFSURI      *from_vfs, *to_vfs;
+	GnomeVFSFileInfo *info;
 	char  	         *from, *to;
+	gboolean          to_vfs_is_dir;
 
 	if (argc != 3) {
 		fprintf (stderr, "Usage: %s <from> <to>\n", argv[0]);
@@ -70,8 +74,38 @@ main (int argc, char **argv)
 		return 1;
 	}
 
-	result = gnome_vfs_move (from, to, TRUE);
+	from_vfs = gnome_vfs_uri_new (from);
+	to_vfs = gnome_vfs_uri_new (to);
+
+	info = gnome_vfs_file_info_new ();
+	result = gnome_vfs_get_file_info_uri (to_vfs, info,
+					      GNOME_VFS_FILE_INFO_DEFAULT);
+	to_vfs_is_dir = (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE &&
+			 info->type == GNOME_VFS_FILE_TYPE_DIRECTORY);
+	gnome_vfs_file_info_unref (info);
+
+	show_result (result, "move (getting target file info)", from, to);
+
+	if (to_vfs_is_dir) {
+		GnomeVFSURI *old_to_vfs = to_vfs;
+		char *short_name;
+
+		short_name = gnome_vfs_uri_extract_short_name (from_vfs);
+		to_vfs = gnome_vfs_uri_append_string (old_to_vfs, short_name);
+
+		gnome_vfs_uri_unref (old_to_vfs);
+		g_free (short_name);
+	}
+
+	result = gnome_vfs_xfer_uri (from_vfs, to_vfs,
+				     GNOME_VFS_XFER_REMOVESOURCE,
+				     GNOME_VFS_XFER_ERROR_MODE_ABORT,
+				     GNOME_VFS_XFER_OVERWRITE_MODE_ABORT,
+				     NULL, NULL);
 	show_result (result, "move", from, to);
+
+	gnome_vfs_uri_unref (from_vfs);
+	gnome_vfs_uri_unref (to_vfs);
 
 	g_free (from);
 	g_free (to);
