From f79806bb27894f8103ab51e0a49652cec42160fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sun, 1 Jun 2008 15:24:55 +0200 Subject: [PATCH] Fix opening files from command line with a relative path --- src/sokoke.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sokoke.c b/src/sokoke.c index 49d836b6..d22c1371 100644 --- a/src/sokoke.c +++ b/src/sokoke.c @@ -30,6 +30,14 @@ sokoke_magic_uri (const gchar* uri, const gchar* default_search_uri) // Add file:// if we have a local path if (g_path_is_absolute (uri)) return g_strconcat ("file://", uri, NULL); + // Construct an absolute path if the file is relative + if (g_file_test (uri, G_FILE_TEST_EXISTS) && g_file_test (uri, G_FILE_TEST_IS_REGULAR)) + { + gchar* current_dir = g_get_current_dir (); + gchar* result = g_strconcat ("file://", current_dir, G_DIR_SEPARATOR_S, uri, NULL); + g_free (current_dir); + return result; + } // Do we need to add a protocol? if (!strstr (uri, "://")) {