mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-08 11:39:40 +02:00
win32: improve the package installation dir lookup
As an example, the core of gedit is in a private library placed in %INSTALLDIR%/lib/gedit/libgedit.dll Before this patch we would get %INSTALLDIR%/lib/gedit as the installation package dir, while what we actually want is to get %INSTALLDIR% https://bugzilla.gnome.org/show_bug.cgi?id=733934
This commit is contained in:
parent
905a8e655c
commit
786590fe93
@ -238,23 +238,44 @@ g_win32_error_message (gint error)
|
|||||||
gchar *
|
gchar *
|
||||||
g_win32_get_package_installation_directory_of_module (gpointer hmodule)
|
g_win32_get_package_installation_directory_of_module (gpointer hmodule)
|
||||||
{
|
{
|
||||||
|
gchar *filename;
|
||||||
gchar *retval;
|
gchar *retval;
|
||||||
gchar *p;
|
gchar *p;
|
||||||
wchar_t wc_fn[MAX_PATH];
|
wchar_t wc_fn[MAX_PATH];
|
||||||
|
|
||||||
|
/* NOTE: it relies that GetModuleFileNameW returns only canonical paths */
|
||||||
if (!GetModuleFileNameW (hmodule, wc_fn, MAX_PATH))
|
if (!GetModuleFileNameW (hmodule, wc_fn, MAX_PATH))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
retval = g_utf16_to_utf8 (wc_fn, -1, NULL, NULL, NULL);
|
filename = g_utf16_to_utf8 (wc_fn, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
if ((p = strrchr (retval, G_DIR_SEPARATOR)) != NULL)
|
if ((p = strrchr (filename, G_DIR_SEPARATOR)) != NULL)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
|
retval = g_strdup (filename);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
p = strrchr (retval, G_DIR_SEPARATOR);
|
p = strrchr (retval, G_DIR_SEPARATOR);
|
||||||
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
|
if (p == NULL)
|
||||||
g_ascii_strcasecmp (p + 1, "lib") == 0))
|
break;
|
||||||
|
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
|
if (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
|
||||||
|
g_ascii_strcasecmp (p + 1, "lib") == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (p != NULL);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
g_free (retval);
|
||||||
|
retval = filename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
#ifdef G_WITH_CYGWIN
|
#ifdef G_WITH_CYGWIN
|
||||||
/* In Cygwin we need to have POSIX paths */
|
/* In Cygwin we need to have POSIX paths */
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user