From 490f0b5228d4972ba16ce375cf3a6989a20ae113 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Wed, 8 Jun 2011 17:39:56 +0300 Subject: Simplify ephy_string_commandline_args_to_uris() No need to use realpath(3), we're in 2011 now. https://bugzilla.gnome.org/show_bug.cgi?id=652120 --- lib/ephy-string.c | 51 ++++++++++----------------------------------------- 1 file changed, 10 insertions(+), 41 deletions(-) (limited to 'lib') diff --git a/lib/ephy-string.c b/lib/ephy-string.c index 72aa582be..fe5f47cd3 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -512,6 +512,7 @@ char ** ephy_string_commandline_args_to_uris (char **arguments, GError **error) { gchar **args; + GFile *file; guint i; if (arguments == NULL) @@ -521,48 +522,16 @@ ephy_string_commandline_args_to_uris (char **arguments, GError **error) for (i = 0; arguments[i] != NULL; ++i) { - char *uri, *path; -#ifdef PATH_MAX - char rpath[PATH_MAX]; -#else - char *rpath = NULL; -#endif - - path = realpath (arguments[i], rpath); - if (path != NULL) - { - uri = g_locale_to_utf8 (path, -1, - NULL, NULL, error); -#ifndef PATH_MAX - free (path); -#endif - } - else - { - uri = g_locale_to_utf8 (arguments[i], -1, - NULL, NULL, error); - } - - if (uri != NULL) - { - /* If it's a file, use g_file_new_for_commandline_arg, - * so we get the right escaping. - */ - if (path != NULL) - { - GFile *file; - file = g_file_new_for_commandline_arg (uri); - args[i] = g_file_get_uri (file); - g_object_unref (file); - g_free (uri); - } - else - { - args[i] = uri; - } + file = g_file_new_for_commandline_arg (arguments [i]); + if (g_file_query_exists (file, NULL)) { + args[i] = g_file_get_uri (file); } else { - g_strfreev (args); - return NULL; + args[i] = g_locale_to_utf8 (arguments [i], -1, + NULL, NULL, error); + if (error && *error) { + g_strfreev (args); + return NULL; + } } } -- cgit v1.2.3