]> spindle.queued.net Git - midori/commitdiff
Fix opening files from command line with a relative path
authorEnrico Tröger <enrico.troeger@uvena.de>
Sun, 1 Jun 2008 13:24:55 +0000 (15:24 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 1 Jun 2008 13:24:55 +0000 (15:24 +0200)
src/sokoke.c

index 49d836b67605eaf15495bb7771acbc6acafb6f6e..d22c1371aa4c16354c523f51c35abdcf76d9e1ef 100644 (file)
@@ -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, "://"))
     {