Rather than always calling out to g_file_get_path() (which
might block, whatever the documentation might say), postpone
the call until we actually need it.
https://bugzilla.gnome.org/show_bug.cgi?id=708753
{
GFile *file;
char *result = NULL;
- char *path, *name;
+ char *path = NULL;
+ char *name;
file = g_file_new_for_uri (uri);
- path = g_file_get_path (file);
- g_object_unref (file);
switch (macro)
{
break;
case 'f':
case 'F':
+ path = g_file_get_path (file);
if (path)
result = g_shell_quote (path);
break;
case 'd':
case 'D':
+ path = g_file_get_path (file);
if (path)
{
name = g_path_get_dirname (path);
break;
case 'n':
case 'N':
+ path = g_file_get_path (file);
if (path)
{
name = g_path_get_basename (path);
break;
}
+ g_object_unref (file);
g_free (path);
return result;