[epiphany] Simplify ephy_string_commandline_args_to_uris()



commit 490f0b5228d4972ba16ce375cf3a6989a20ae113
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Wed Jun 8 17:39:56 2011 +0300

    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 files changed, 10 insertions(+), 41 deletions(-)
---
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index 72aa582..fe5f47c 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;
+			}
 		}
 	}
 



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