Commit 4d32d902 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

[Win32] Look up installation prefix at run-time, replace prefix in

2004-03-15  Tor Lillqvist  <tml@iki.fi>

	* queryloaders.c (main): [Win32] Look up installation prefix at
	run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141)
parent ba7a9517
2004-03-15 Tor Lillqvist <tml@iki.fi>
* queryloaders.c (main): [Win32] Look up installation prefix at
run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141)
Merges from stable branch that had been left out. (#136282, J. Ali
Harlow)
Harlow):
Changes for run-time lookup of installation location on Win32:
......
......@@ -45,6 +45,10 @@
#endif
#define SOEXT_LEN (strlen (SOEXT))
#ifdef G_OS_WIN32
#include <windows.h>
#endif
static void
print_escaped (const char *str)
{
......@@ -203,6 +207,45 @@ int main (int argc, char **argv)
{
gint i;
#ifdef G_OS_WIN32
gchar libdir[sizeof (PIXBUF_LIBDIR) + 100];
gchar runtime_prefix[1000];
gchar *slash;
strcpy (libdir, PIXBUF_LIBDIR);
if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 &&
(PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '/' ||
PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '\\')) {
/* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it
* normally is. Replace that prefix in PIXBUF_LIBDIR
* with the installation directory on this machine.
* We assume this invokation of
* gdk-pixbuf-query-loaders is run from either a "bin"
* subdirectory of the installation directory, or in
* the insallation directory itself.
*/
GetModuleFileName (NULL, runtime_prefix, sizeof (runtime_prefix));
slash = strrchr (runtime_prefix, '\\');
*slash = '\0';
slash = strrchr (runtime_prefix, '\\');
if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
*slash = '\0';
}
if (strlen (runtime_prefix) + 1 + strlen (PIXBUF_LIBDIR) - strlen (GTK_PREFIX) < sizeof (libdir)) {
strcpy (libdir, runtime_prefix);
strcat (libdir, "/");
strcat (libdir, PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1);
}
}
#undef PIXBUF_LIBDIR
#define PIXBUF_LIBDIR libdir
#endif
g_printf ("# GdkPixbuf Image Loader Modules file\n"
"# Automatically generated file, do not edit\n"
"#\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment