diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2011-06-08 22:39:56 +0800 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2011-06-09 00:24:22 +0800 |
commit | 490f0b5228d4972ba16ce375cf3a6989a20ae113 (patch) | |
tree | 8325221325c75787fc26166632d03c3a317e8a28 /lib | |
parent | 769cf77926d58dc75e1f031b15433522ecd8d9a2 (diff) | |
download | gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar.gz gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar.bz2 gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar.lz gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar.xz gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.tar.zst gsoc2013-epiphany-490f0b5228d4972ba16ce375cf3a6989a20ae113.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-string.c | 51 |
1 files changed, 10 insertions, 41 deletions
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; + } } } |