From 0d42950c7ce53704ea83f34e85e120927f6b96c2 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 26 Feb 2009 08:32:48 +0000 Subject: [PATCH] Add helper to get the path to use for symlinks that also works for 2009-02-26 Alexander Larsson * 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 == svn path=/trunk/; revision=15024 --- ChangeLog | 11 ++++++++ .../nautilus-file-operations.c | 28 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74af72d57..d946d88ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-02-26 Alexander Larsson + + * 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 == + 2009-02-26 Alexander Larsson * libnautilus-private/nautilus-global-preferences.c: diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c index 0fa106d6b..ec6f2b98c 100644 --- a/libnautilus-private/nautilus-file-operations.c +++ b/libnautilus-private/nautilus-file-operations.c @@ -4964,6 +4964,29 @@ report_link_progress (CopyMoveJob *link_job, int total, int left) 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 @@ link_file (CopyMoveJob *job, 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 @@ link_file (CopyMoveJob *job, 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, -- GitLab