nautilus r15024 - in trunk: . libnautilus-private



Author: alexl
Date: Thu Feb 26 08:32:48 2009
New Revision: 15024
URL: http://svn.gnome.org/viewvc/nautilus?rev=15024&view=rev

Log:
2009-02-26  Alexander Larsson  <alexl redhat com>

        * libnautilus-private/nautilus-file-operations.c:
        (get_abs_path_for_symlink):
	Add helper to get the path to use for symlinks that also
	works for non-local files.
        (link_file):
	Use get_abs_path_for_symlink() for target of symlink so that
	it works for remote files too.
	Also, fix GFile comparison to use g_file_equal, not ==



Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-file-operations.c

Modified: trunk/libnautilus-private/nautilus-file-operations.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file-operations.c	(original)
+++ trunk/libnautilus-private/nautilus-file-operations.c	Thu Feb 26 08:32:48 2009
@@ -4964,6 +4964,29 @@
 	nautilus_progress_info_set_progress (job->progress, left, total);
 }
 
+static char *
+get_abs_path_for_symlink (GFile *file)
+{
+	GFile *root, *parent;
+	char *relative, *abs;
+	
+	if (g_file_is_native (file)) {
+		return g_file_get_path (file);
+	}
+
+	root = g_object_ref (file);
+	while ((parent = g_file_get_parent (root)) != NULL) {
+		g_object_unref (root);
+		root = parent;
+	}
+	
+	relative = g_file_get_relative_path (root, file);
+	g_object_unref (root);
+	abs = g_strconcat ("/", relative, NULL);
+	g_free (relative);
+	return abs;
+}
+
 
 static void
 link_file (CopyMoveJob *job,
@@ -4988,7 +5011,7 @@
 	count = 0;
 
 	src_dir = g_file_get_parent (src);
-	if (src_dir == dest_dir) {
+	if (g_file_equal (src_dir, dest_dir)) {
 		count = 1;
 	}
 	g_object_unref (src_dir);
@@ -5000,7 +5023,8 @@
  retry:
 	error = NULL;
 	not_local = FALSE;
-	path = g_file_get_path (src);
+	
+	path = get_abs_path_for_symlink (src);
 	if (path == NULL) {
 		not_local = TRUE;
 	} else if (g_file_make_symbolic_link (dest,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]