Add macros G_WIN32_DLLMAIN_FOR_DLL_NAME and G_HARDCODED_PATH_WRAPPER.

2001-10-23  Tor Lillqvist  <tml@iki.fi>

	* glib/gutils.h: Add macros G_WIN32_DLLMAIN_FOR_DLL_NAME and
	G_HARDCODED_PATH_WRAPPER. These are used to avoid hardcoding path
	names into Windows DLLs.

	* glib/gutils.c: Use them for GLIB_LOCALEDIR.

	* glib/gwin32.c (get_package_directory_from_module): Plug a small
	memory leak. Minor code reordering.
	(g_win32_get_package_installation_subdirectory):  Allow empty subdir.
This commit is contained in:
Tor Lillqvist
2001-10-22 23:19:19 +00:00
committed by Tor Lillqvist
parent a0b08581c0
commit 3984621bd3
11 changed files with 171 additions and 50 deletions

View File

@@ -611,9 +611,18 @@ get_package_directory_from_module (gchar *module_name)
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
{
G_UNLOCK (module_dirs);
g_free (fn);
return NULL;
}
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
p = strrchr (fn, G_DIR_SEPARATOR);
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
g_ascii_strcasecmp (p + 1, "lib") == 0))
*p = '\0';
#ifdef G_WITH_CYGWIN
/* In Cygwin we need to have POSIX paths */
{
@@ -625,14 +634,6 @@ get_package_directory_from_module (gchar *module_name)
}
#endif
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
p = strrchr (fn, G_DIR_SEPARATOR);
if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0 ||
g_ascii_strcasecmp (p + 1, "lib") == 0))
*p = '\0';
g_hash_table_insert (module_dirs, module_name ? module_name : "", fn);
G_UNLOCK (module_dirs);
@@ -770,7 +771,7 @@ g_win32_get_package_installation_subdirectory (gchar *package,
prefix = g_win32_get_package_installation_directory (package, dll_name);
sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
sep = ((subdir != NULL && strlen (subdir) > 0) || prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
"" : G_DIR_SEPARATOR_S);
return g_strconcat (prefix, sep, subdir, NULL);