diff options
author | Emmanuele Bassi <ebassi@gmail.com> | 2023-01-05 18:56:52 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gmail.com> | 2023-01-05 18:56:52 +0000 |
commit | 3ba701a4993b2e3a6dd899a3439534ef8d316fbc (patch) | |
tree | 9091e9f0183e5c51caa589b92f21916460c3dcf3 | |
parent | 433464b3f9b12d2e42f85bb7af96574573d85816 (diff) | |
parent | de8c3d770a1604c241bb2035770573b45e1ce1c0 (diff) | |
download | glib-3ba701a4993b2e3a6dd899a3439534ef8d316fbc.tar.gz |
Merge branch 'backport-3160-win32-app-info-glib-2-74' into 'glib-2-74'
Backport !3160 “GWin32AppInfo: Check for local file path first” to glib-2-74
See merge request GNOME/glib!3166
-rw-r--r-- | gio/gwin32appinfo.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c index 6ff259f7d..1bfcaf93d 100644 --- a/gio/gwin32appinfo.c +++ b/gio/gwin32appinfo.c @@ -4334,10 +4334,25 @@ expand_macro_single (char macro, file_or_uri *obj) case '8': case '9': /* TODO: handle 'l' and 'd' differently (longname and desktop name) */ - if (obj->uri) - result = g_strdup (obj->uri); - else if (obj->file) - result = g_strdup (obj->file); + if (obj->file) + { + result = g_strdup (obj->file); + } + else if (obj->uri) + { + const char *prefix = "file:///"; + const size_t prefix_len = strlen (prefix); + + if (g_str_has_prefix (obj->uri, prefix) == 0 && obj->uri[prefix_len] != 0) + { + GFile *file = g_file_new_for_uri (obj->uri); + result = g_file_get_path (file); + g_object_unref (file); + } + + if (!result) + result = g_strdup (obj->uri); + } break; case 'u': case 'U': @@ -5283,14 +5298,18 @@ make_item_array (gboolean for_files, } hr = SHParseDisplayName (file_or_uri_utf16, NULL, &item_ids[i], 0, NULL); - g_free (file_or_uri_utf16); if (FAILED (hr)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "File or URI `%S' cannot be parsed by SHParseDisplayName: 0x%lx", file_or_uri_utf16, hr); + "File or URI `%S' cannot be parsed by SHParseDisplayName: 0x%lx", + file_or_uri_utf16, hr); + + g_free (file_or_uri_utf16); break; } + + g_free (file_or_uri_utf16); } if (i == count) |