Index: gedit/gedit-document.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-document.c,v
retrieving revision 1.101
diff -u -r1.101 gedit-document.c
--- gedit/gedit-document.c	31 Oct 2004 21:15:28 -0000	1.101
+++ gedit/gedit-document.c	13 Nov 2004 04:02:30 -0000
@@ -1752,22 +1752,42 @@
 gedit_document_save_as_real (GeditDocument* doc, const gchar *uri, const GeditEncoding *encoding,
 			     gboolean create_backup_copy, GError **error)
 {
-	gchar *filename; /* Filename without URI scheme */
-	gchar *real_filename; /* Final filename with no symlinks */
-	gchar *backup_filename; /* Backup filename, like real_filename.bak */
-	gchar *temp_filename; /* Filename for saving */
-	gchar *slashpos;
-	gchar *dirname;
-	mode_t saved_umask;
-	struct stat st;
-	gchar *chars = NULL;
-	gint chars_len;
-	gint fd;
-	gint retval;
-	gboolean res;
-	gboolean add_cr;
+	GnomeVFSURI *vuri;
+	GnomeVFSResult result;
+	GnomeVFSHandle *handle;
+	GnomeVFSHandle *rhandle;
+	GnomeVFSFileSize wsize;
+
+	GnomeVFSFileInfo *orig;
+	GnomeVFSSetFileInfoMask orig_mask;
+
+	gchar *dir;
+	gchar *base;
+	GnomeVFSFileInfo *info;
+	gboolean can_write_dir;
+	gchar *backup_uri;
+	const gchar *ext;
+	gchar *tmp;
+	gboolean is_tmp_dir;
+	gboolean renamed;
+	gboolean restore;
+	GnomeVFSResult restore_res;
+	gchar buffer[ 8192 ];
+	GnomeVFSFileSize vfssize;
+	uid_t user;
+	GnomeVFSSetFileInfoMask mask;
+	
+	gboolean ret;
+
+
+	gchar *msg;
 	GtkTextIter start_iter;
 	GtkTextIter end_iter;
+	gchar *chars;
+	guint chars_len;
+	gboolean add_cr;
+	GnomeVFSFilePermissions perms;
+	mode_t saved_umask;
 	
 	gedit_debug (DEBUG_DOCUMENT, "");
 
@@ -1776,116 +1796,25 @@
 	g_return_val_if_fail (uri != NULL, FALSE);
 	g_return_val_if_fail (encoding != NULL, FALSE);
 
-	retval = FALSE;
-
-	filename = NULL;
-	real_filename = NULL;
-	backup_filename = NULL;
-	temp_filename = NULL;
-
-	/* We don't support non-file:/// stuff */
-
-	if (!gedit_utils_uri_has_file_scheme (uri))
-	{
-		gchar *error_message;
-		gchar *scheme_string;
-
-		gchar *temp = gnome_vfs_get_uri_scheme (uri);
-		scheme_string = gedit_utils_make_valid_utf8 (temp);
-		g_free (temp);
-
-		if (scheme_string != NULL)
-		{
-			error_message = g_strdup_printf (
-				_("gedit cannot handle %s: locations in write mode."),
-                               	scheme_string);
-
-			g_free (scheme_string);
-		}
-		else
-			error_message = g_strdup_printf (
-				_("gedit cannot handle this kind of location in write mode."));
-
-		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, EROFS, error_message);
-		g_free (error_message);
-		return FALSE;
-	}
-
-	/* Get filename from uri */
-	filename = gnome_vfs_get_local_path_from_uri (uri);
-
-	if (!filename)
-	{
-		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, 0,
-			     _("Invalid filename."));
-		goto out;
-	}
-
-	/* Get the real filename and file permissions */
-
-	real_filename = follow_symlinks (filename, error);
-
-	if (!real_filename)
-		goto out;
-
-	/* Get the directory in which the real filename lives */
-
-	slashpos = strrchr (real_filename, G_DIR_SEPARATOR);
-
-	if (slashpos)
-	{
-		dirname = g_strdup (real_filename);
-		dirname[slashpos - real_filename + 1] = '\0';
-	}
-	else
-		dirname = g_strdup (".");
-
-	/* If there is not an existing file with that name, compute the
-	 * permissions and uid/gid that we will use for the newly-created file.
-	 */
-
-	if (stat (real_filename, &st) != 0)
-	{
-		struct stat dir_st;
-		int result;
-
-		/* File does not exist? */
-		create_backup_copy = FALSE;
-
-		/* Use default permissions */
-		saved_umask = umask(0);
-		st.st_mode = 0666 & ~saved_umask;
-		umask(saved_umask);
-		st.st_uid = getuid ();
-
-		result = stat (dirname, &dir_st);
-
-		if (result == 0 && (dir_st.st_mode & S_ISGID))
-			st.st_gid = dir_st.st_gid;
-		else
-			st.st_gid = getgid ();
+	
+	ret = FALSE;
+	
+	if( error ) {
+		*error = NULL;
 	}
 
-	/* Save to a temporary file.  We set the umask because some (buggy)
-	 * implementations of mkstemp() use permissions 0666 and we want 0600.
-	 */
-
-	temp_filename = g_build_filename (dirname, ".gedit-save-XXXXXX", NULL);
-	g_free (dirname);
+	info = orig = NULL;
+	vuri = NULL;
+	dir = base = backup_uri = NULL;
+	is_tmp_dir = FALSE;
 
-	saved_umask = umask (0077);
-	fd = g_mkstemp (temp_filename); /* this modifies temp_filename to the used name */
-	umask (saved_umask);
-
-	if (fd == -1)
-	{
-		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, " ");
-		goto out;
-	}
+	result = GNOME_VFS_ERROR_GENERIC;
 
-	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start_iter, &end_iter);
+	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), 
+			&start_iter, &end_iter);
 	chars = gtk_text_buffer_get_slice (GTK_TEXT_BUFFER (doc),
-					   &start_iter, &end_iter, TRUE);
+					   &start_iter, &end_iter, 
+					   TRUE);
 
 	if (encoding != gedit_encoding_get_utf8 ())
 	{
@@ -1902,8 +1831,6 @@
 			/* Conversion error */
 			g_propagate_error (error, conv_error);
 
-			close (fd);
-			unlink (temp_filename);
 			goto out;
 		}
 		else
@@ -1917,116 +1844,387 @@
 
 	add_cr = (*(chars + chars_len - 1) != '\n');
 
-	/* Save the file content */
-	res = (write (fd, chars, chars_len) == chars_len);
+	vuri = gnome_vfs_uri_new (uri);
+	/* can't proceed with an invalid uri */
+	if (!vuri) 
+	{
+		ret = FALSE;
+		result = GNOME_VFS_ERROR_INVALID_URI;
+		goto out;
+	}
 
-	if (res && add_cr)
-		/* Add \n if needed */
-		res = (write (fd, "\n", 1) == 1);
+	/* Use default permissions */
+	saved_umask = umask(0);
+	perms = (GNOME_VFS_PERM_USER_READ |
+		 GNOME_VFS_PERM_USER_WRITE |
+		 GNOME_VFS_PERM_GROUP_READ |
+		 GNOME_VFS_PERM_GROUP_WRITE |
+		 GNOME_VFS_PERM_OTHER_READ |
+		 GNOME_VFS_PERM_OTHER_WRITE ) &
+		~saved_umask;
+	umask (saved_umask);
+	
+	/* no need for backups if the file doesn't already exist,
+	 * not using uri_exists() here as we want the info as well */
+	orig = gnome_vfs_file_info_new ();
+	result = gnome_vfs_get_file_info (uri, orig,
+			GNOME_VFS_FILE_INFO_FOLLOW_LINKS |
+			GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
+	if (result == GNOME_VFS_OK) 
+	{
+		/* file already exists */
+		orig_mask = GNOME_VFS_SET_FILE_INFO_OWNER;
+		if (orig->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) 
+		{
+			orig_mask |= GNOME_VFS_SET_FILE_INFO_PERMISSIONS;
+		}
+		/* follow symlink, is this correct behaviour ? */	
+		if (GNOME_VFS_FILE_INFO_SYMLINK (orig)) 
+		{
+			uri = orig->symlink_name;
+			gnome_vfs_uri_unref (vuri);
+			vuri = gnome_vfs_uri_new (uri);
+			if (!vuri) 
+			{
+				ret = FALSE;
+				result = GNOME_VFS_ERROR_INVALID_URI;
+				goto out;
+			}
+		}
+	} 
+	else 
+	{		
+		gnome_vfs_file_info_unref (orig);
+		orig = NULL;
+	}
 
-	if (!res)
+	/* can we write to the directory? */
+	dir = gnome_vfs_uri_to_string (vuri, GNOME_VFS_URI_HIDE_NONE);
+	tmp = strrchr (dir, '/');
+	if (tmp) 
+	{
+		*tmp = '\0';
+	
+		info = gnome_vfs_file_info_new ();
+		result = gnome_vfs_get_file_info (dir, info,
+				GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
+	}
+	if ( (!tmp) || result != GNOME_VFS_OK) 
+	{
+		ret = FALSE;
+		goto out;
+	}
+	can_write_dir = ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) && (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE));
+	/* can we set the necessary permissions? */
+	if (can_write_dir && orig) 
+	{
+		result = gnome_vfs_set_file_info (uri, orig, orig_mask);
+	}
+	
+	ext = gedit_prefs_manager_get_backup_extension ();
+	base = gnome_vfs_uri_extract_short_name (vuri);
+	renamed = FALSE;
+	if ((! create_backup_copy) || (! can_write_dir)) 
+	{
+		/* can't write to the directory, or we don't
+		 * want a backup to be kept, make a backup copy
+		 * in TMPDIR, this gets erased if we
+		 * successfully save.*/
+		tmp = g_strconcat (base, "-XXXXXX", NULL);
+		backup_uri = gedit_utils_tmp_filename (tmp, NULL);
+		g_free (tmp);
+
+		is_tmp_dir = TRUE;
+		result = GNOME_VFS_OK;
+		if (! gedit_utils_copy_file (uri, backup_uri, 
+					GNOME_VFS_XFER_DEFAULT,
+					GNOME_VFS_XFER_ERROR_MODE_ABORT,
+					GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+					NULL, NULL, error)) 
+		{
+			/* failed to create backup */
+			result = GNOME_VFS_ERROR_IO;
+			is_tmp_dir = FALSE;
+		} 
+	} 
+	else if (result != GNOME_VFS_OK || 
+			(orig && (GNOME_VFS_FILE_INFO_SYMLINK (orig) ||
+				  orig->link_count > 0))) 
+	{
+		/* can't set original permissions so can't create
+		 * backup via renaming, or file is a link,
+		 * make backup in dir by copying */
+		tmp = g_strconcat (base, ext, NULL);
+		backup_uri = g_build_filename (dir, tmp, NULL);
+		g_free (tmp);
+
+		result = GNOME_VFS_OK;	
+		if (!gedit_utils_copy_file (uri, backup_uri,
+					GNOME_VFS_XFER_DEFAULT,
+					GNOME_VFS_XFER_ERROR_MODE_ABORT,
+					GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+					NULL, NULL, error)) 
+		{
+			/* failed to create backup */
+			result = GNOME_VFS_ERROR_IO;
+		}
+	} 
+	else if (orig) 
 	{
-		gchar *msg;
+		/* create backup by renaming uri */
+		
+		tmp = g_strconcat (base, ext, NULL);
+		backup_uri = g_build_filename (dir, tmp, NULL);
 
-		switch (errno)
+		/* erase if it already exists */
+		result = gnome_vfs_unlink (backup_uri);
+		if (result == GNOME_VFS_OK || 
+		    result == GNOME_VFS_ERROR_NOT_FOUND) 
 		{
-			case ENOSPC:
-				msg = _("There is not enough disk space to save the file.\n"
-					"Please free some disk space and try again.");
-				break;
+			g_free (orig->name);
+			orig->name = tmp;
 
-			case EFBIG:
-				msg = _("The disk where you are trying to save the file has "
-					"a limitation on file sizes.  Please try saving "
-					"a smaller file or saving it to a disk that does not "
-					"have this limitation.");
-				break;
+			result = gnome_vfs_set_file_info (uri, orig,
+					GNOME_VFS_SET_FILE_INFO_NAME);
+			/* restore orig base name */	
+			g_free (tmp);
+			orig->name = g_strdup (base);
 
-			default:
-				msg = " ";
-				break;
+			renamed = TRUE;
+			perms = orig->permissions;
 		}
-
-		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, msg);
-		close (fd);
-		unlink (temp_filename);
-		goto out;
 	}
 
-	if (close (fd) != 0)
+	if (result != GNOME_VFS_OK) 
 	{
-		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, " ");
-		unlink (temp_filename);
+		/* failed to create backup */
+		ret = FALSE;
+		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR,
+			(gint)result,
+			gnome_vfs_result_to_string (result));
 		goto out;
 	}
-
-	/* Move the original file to a backup */
-
-	if (create_backup_copy)
+	
+	wsize = 0;
+	
+	/* if the file didn't exist, or we renamed it to create the
+	 * backup we need to create/recreate the file */
+	if (renamed || ! orig) 
 	{
-		gchar *bak_ext;
-		gint result;
-
-		bak_ext = gedit_prefs_manager_get_backup_extension ();
-		
-		backup_filename = g_strconcat (real_filename, 
-					       bak_ext,
-					       NULL);
-
-		g_free (bak_ext);
-		
-		result = rename (real_filename, backup_filename);
-
-		if (result != 0)
+		result = gnome_vfs_create_uri (&handle, vuri,
+					       GNOME_VFS_OPEN_WRITE,
+					       FALSE, perms);
+	} 
+	else 
+	{
+		/* not creating backup, or backup was a copy,
+		 * open and truncate */
+		result = gnome_vfs_open_uri (&handle, vuri,
+				GNOME_VFS_OPEN_WRITE);
+	}
+	restore = FALSE;
+	if (result != GNOME_VFS_OK) 
+	{
+		ret = FALSE;
+	} 
+	else 
+	{
+		/* truncate to 0 */
+		while (chars_len > 0 && result == GNOME_VFS_OK) 
 		{
-			g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno,
-				     _("Could not create a backup file."));
-			unlink (temp_filename);
-			goto out;
+			restore = TRUE;
+			
+			result = gnome_vfs_write (handle, chars, 
+					chars_len, &vfssize);
+			chars_len -= vfssize;
+			chars += vfssize;
+			wsize += vfssize;
 		}
+		if( result == GNOME_VFS_OK && add_cr ) {
+			result = gnome_vfs_write (handle, "\n", 1,
+					&vfssize);
+		}
+		ret = (result == GNOME_VFS_OK);
+		gnome_vfs_truncate_handle (handle, wsize);
+		gnome_vfs_close (handle);
 	}
-
-	/* Move the temp file to the original file */
-
-	if (rename (temp_filename, real_filename) != 0)
+	
+	/* set original file permissions on new file */
+	if (ret) 
 	{
-		gint saved_errno;
-
-		saved_errno = errno;
-
-		if (create_backup_copy && rename (backup_filename, real_filename) != 0)
-			g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno,
-				     " ");
-		else
-			g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, saved_errno,
-				     " ");
+		mask = GNOME_VFS_SET_FILE_INFO_PERMISSIONS |
+			GNOME_VFS_SET_FILE_INFO_OWNER;
+		if (renamed) 
+		{
+			/* set original perms */
+			gnome_vfs_set_file_info (uri, orig, mask);
+		} 
+		else if (orig) 
+		{
+			user = orig->uid;
 
+			/* set backup file perms correctly,
+			 *
+			 * owned by current user, group as original */
+			orig->uid = getuid ();
+			if (gnome_vfs_set_file_info (backup_uri, orig,
+						mask ) != GNOME_VFS_OK) {
+				/* failed to set perms, set group perms
+				 * to same as other perms */
+				perms = orig->permissions;
+				orig->permissions = (perms & (GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_OTHER_ALL)) | ((perms & GNOME_VFS_PERM_OTHER_ALL) << 3);
+				mask = GNOME_VFS_SET_FILE_INFO_PERMISSIONS;	
+				gnome_vfs_set_file_info (backup_uri, 
+						orig, mask);
+				orig->permissions = perms;
+			}
+			
+			orig->uid = user;
+		}
+		gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), 
+				FALSE);
 		goto out;
 	}
 
-	/* Restore permissions.  There is not much error checking we can do
-	 * here, I'm afraid.  The final data is saved anyways.
-	 */
-
-	chmod (real_filename, st.st_mode);
-	chown (real_filename, st.st_uid, st.st_gid);
-
-	gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE);
+	switch (result)
+	{
+		case GNOME_VFS_ERROR_NO_SPACE:
+			msg = _("There is not enough disk space to save the file.\n"
+				"Please free some disk space and try again.");
+			break;
+
+		case GNOME_VFS_ERROR_TOO_BIG:
+			msg = _("The disk where you are trying to save the file has "
+				"a limitation on file sizes.  Please try saving "
+				"a smaller file or saving it to a disk that does not "
+				"have this limitation.");
+			break;
+
+		default:
+			msg = " ";
+			break;
+	}
 
-	retval = TRUE;
+	g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, msg);
 
-	/* Done */
+	if (! restore)
+		goto out;
+	
+	/* restore from backup */
 
- out:
+	restore_res = GNOME_VFS_OK;
+	if (renamed) 
+	{
+		/* erase if it already exists */
+		restore_res = gnome_vfs_unlink (uri);
+		if (restore_res == GNOME_VFS_OK) 
+		{
+			restore_res = gnome_vfs_set_file_info (backup_uri, 
+					orig,
+					GNOME_VFS_SET_FILE_INFO_NAME);
+		}
+	} 
+	else 
+	{
+		/* truncate uri, open backup_uri, write */
 
-	g_free (chars);
+		rhandle = NULL;
+		handle = NULL;
+		restore_res = gnome_vfs_open (&handle, uri,
+				GNOME_VFS_OPEN_WRITE);
+		if (restore_res == GNOME_VFS_OK) 
+		{
+			restore_res = gnome_vfs_truncate_handle (handle,
+					0);
+		}
+		if (restore_res == GNOME_VFS_OK) 
+		{
+			restore_res = gnome_vfs_open (&rhandle,
+					backup_uri,
+					GNOME_VFS_OPEN_READ);
+		}
+		if (restore_res == GNOME_VFS_OK) 
+		{
+			while (restore_res == GNOME_VFS_OK) 
+			{
+				vfssize = 0;
+				restore_res = gnome_vfs_read (rhandle,
+						buffer, 8192,
+						&vfssize);
+				if (restore_res == GNOME_VFS_OK || 
+					(restore_res == GNOME_VFS_ERROR_EOF && vfssize > 0)) 
+				{
+					restore_res = gnome_vfs_write (handle, buffer, vfssize, &vfssize);
+				}
+			}	
+			if (restore_res == GNOME_VFS_ERROR_EOF) 
+			{
+				restore_res = GNOME_VFS_OK;
+			}
+		}
+		if (handle) 
+		{
+			gnome_vfs_close (handle);
+		}
+		if (rhandle) 
+		{
+			gnome_vfs_close (rhandle);
+		}
+	}
+	if (restore_res != GNOME_VFS_OK && error && ! *error) 
+	{
+		/* failed to restore backup */
+		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR,
+			(gint)restore_res,
+			"%s\nFailed to restore from backup file: %s\n\nBackup is at %s",
+			gnome_vfs_result_to_string (result),
+			gnome_vfs_result_to_string (restore_res),
+			backup_uri);
 
-	g_free (filename);
-	g_free (real_filename);
-	g_free (backup_filename);
-	g_free (temp_filename);
+		/* prevent erasing of backup file if it is in TMPDIR */
+		is_tmp_dir = FALSE;
+	}
+	
+out:
+	if ((!ret) && error && ! *error) 
+	{
+		g_set_error (error, GEDIT_DOCUMENT_IO_ERROR,
+			(gint)result,
+			gnome_vfs_result_to_string (result));
+	}
 
-	return retval;
+	/* erase backups to TMPDIR after we are done */
+	if (is_tmp_dir) 
+	{
+		gnome_vfs_unlink (backup_uri);
+	}
+	
+	if (dir) 
+	{
+		g_free (dir);
+	}
+	if (base) 
+	{
+		g_free (base);
+	}
+	if (backup_uri) 
+	{
+		g_free (backup_uri);
+	}
+	if (orig) 
+	{
+		gnome_vfs_file_info_unref (orig);
+	}
+	if (info) 
+	{
+		gnome_vfs_file_info_unref (info);
+	}
+	if (vuri) 
+	{
+		gnome_vfs_uri_unref (vuri);
+	}
+	
+	return ret;
 }
 
 gboolean	
Index: gedit/gedit-utils.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-utils.c,v
retrieving revision 1.60
diff -u -r1.60 gedit-utils.c
--- gedit/gedit-utils.c	9 Nov 2004 17:33:40 -0000	1.60
+++ gedit/gedit-utils.c	13 Nov 2004 04:02:30 -0000
@@ -253,6 +253,95 @@
 	return res;
 }
 
+gchar *
+gedit_utils_tmp_filename (const gchar *base, const gchar *extension)
+{
+	int fd;
+	const gchar *tmp;
+	gchar *name;
+	
+	
+	tmp = g_getenv( "TMPDIR" );
+	if (!tmp)
+	{
+#ifdef P_tmpdir
+		tmp = P_tmpdir;
+#else
+		tmp = "/tmp";
+#endif
+	}
+	name = g_build_filename( tmp, base, NULL );
+
+	fd = g_mkstemp (name);
+
+	if (fd != -1)
+	{
+		unlink (name);
+		close (fd);
+	}
+	else
+	{
+		g_free (name);
+
+		return NULL;
+	}
+
+	if (extension)
+	{
+		gchar *tmp;
+		tmp = g_strconcat (name, ".", extension, NULL);
+		g_free (name);
+		name = tmp;
+	}
+
+	return name;
+}
+
+/* FIXME: provide proper error feedback */
+gboolean gedit_utils_copy_file (const gchar *src, const gchar *dst,
+				GnomeVFSXferOptions options, 
+				GnomeVFSXferErrorMode emode,
+				GnomeVFSXferOverwriteMode omode,
+				GnomeVFSXferProgressCallback progress_cb,
+				gpointer data,
+				GError **error )
+{
+	GnomeVFSURI *src_uri;
+	GnomeVFSURI *dst_uri;
+	GnomeVFSResult result;
+	gboolean retval;
+	
+	if (error)
+		*error = NULL;
+	
+	src_uri = gnome_vfs_uri_new (src);
+	if (!src_uri) 
+	{
+		return FALSE;
+	}
+
+	dst_uri = gnome_vfs_uri_new (dst);
+	if (!dst_uri)
+	{
+		gnome_vfs_uri_unref (src_uri);
+		
+		return FALSE;
+	}
+
+	retval = TRUE;
+	result = gnome_vfs_xfer_uri (src_uri, dst_uri, options,
+			emode, omode, progress_cb, data);
+	if (result != GNOME_VFS_OK)
+	{
+		retval = FALSE;
+	}
+
+	gnome_vfs_uri_unref (src_uri);
+	gnome_vfs_uri_unref (dst_uri);
+	
+	return retval;
+}
+	
 gboolean
 gedit_utils_is_uri_read_only (const gchar* uri)
 {
Index: gedit/gedit-utils.h
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-utils.h,v
retrieving revision 1.32
diff -u -r1.32 gedit-utils.h
--- gedit/gedit-utils.h	9 Nov 2004 17:33:40 -0000	1.32
+++ gedit/gedit-utils.h	13 Nov 2004 04:02:30 -0000
@@ -38,6 +38,7 @@
 #include <atk/atk.h>
 #include <gedit/gedit-encodings.h>
 
+#include <libgnomevfs/gnome-vfs.h>
 
 /* some common error strings, %s must be a file path */
 #define MISSING_FILE    N_("Could not find \"%s\". Please, reinstall gedit.\n")
@@ -53,6 +54,16 @@
 
 gboolean gedit_utils_is_uri_read_only (const gchar* uri);
 gboolean gedit_utils_uri_has_file_scheme (const gchar *uri);
+gchar *gedit_utils_tmp_filename (const gchar *base, 
+				 const gchar *extension);
+
+gboolean gedit_utils_copy_file (const gchar *src, const gchar *dst,
+				GnomeVFSXferOptions options, 
+				GnomeVFSXferErrorMode emode,
+				GnomeVFSXferOverwriteMode omode,
+				GnomeVFSXferProgressCallback progress_cb,
+				gpointer data,
+				GError **error );
 
 GtkWidget *gedit_dialog_add_button (GtkDialog *dialog, 
 				    const gchar* text, 
