Fix opening files from command line with a relative path
This commit is contained in:
parent
4e5afd5041
commit
f79806bb27
1 changed files with 8 additions and 0 deletions
|
@ -30,6 +30,14 @@ sokoke_magic_uri (const gchar* uri, const gchar* default_search_uri)
|
||||||
// Add file:// if we have a local path
|
// Add file:// if we have a local path
|
||||||
if (g_path_is_absolute (uri))
|
if (g_path_is_absolute (uri))
|
||||||
return g_strconcat ("file://", uri, NULL);
|
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?
|
// Do we need to add a protocol?
|
||||||
if (!strstr (uri, "://"))
|
if (!strstr (uri, "://"))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue