diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2009-04-10 13:57:32 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@src.gnome.org> | 2009-04-10 13:57:32 (GMT) |
commit | d21804b94a1e456c77453ed4993105f0979ceaf2 (patch) | |
tree | 09dc085f20a8921ab564d21cf106c477a5f26077 /shell/ev-window.c | |
parent | 5d0383f8b62c2bafd54e18f8914797c50d96d815 (diff) |
Use g_file_make_symbolic_link to create symlinks. Patch by Hib Eris. See
2009-04-10 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-window.c: (ev_window_create_tmp_symlink):
Use g_file_make_symbolic_link to create symlinks. Patch by Hib
Eris. See bug #339172.
svn path=/trunk/; revision=3597
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r-- | shell/ev-window.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c index 0ce2bef..f61e350 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2069,10 +2069,11 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *window) static gchar * ev_window_create_tmp_symlink (const gchar *filename, GError **error) { - gchar *tmp_filename = NULL; - gchar *name; - gint res; - guint i = 0; + gchar *tmp_filename = NULL; + gchar *name; + guint i = 0; + GError *link_error = NULL; + GFile *tmp_file = NULL; name = g_path_get_basename (filename); @@ -2081,29 +2082,32 @@ ev_window_create_tmp_symlink (const gchar *filename, GError **error) if (tmp_filename) g_free (tmp_filename); + if (tmp_file) + g_object_unref (tmp_file); + g_clear_error (&link_error); basename = g_strdup_printf ("%s-%d", name, i++); tmp_filename = g_build_filename (ev_tmp_dir (), basename, NULL); g_free (basename); - } while ((res = symlink (filename, tmp_filename)) != 0 && errno == EEXIST); - - g_free (name); + tmp_file = g_file_new_for_path (tmp_filename); + } while (!g_file_make_symbolic_link (tmp_file, filename, NULL, &link_error) && + g_error_matches (link_error, G_IO_ERROR, G_IO_ERROR_EXISTS)); - if (res != 0 && errno != EEXIST) { - if (error) { - *error = g_error_new (G_FILE_ERROR, - g_file_error_from_errno (errno), - _("Couldn't create symlink ā%sā: %s"), - tmp_filename, strerror (errno)); - } + g_free (name); + g_object_unref (tmp_file); + if (link_error) { + g_propagate_prefixed_error (error, + link_error, + _("Couldn't create symlink ā%sā: "), + tmp_filename); g_free (tmp_filename); - + return NULL; } - + return tmp_filename; } |