diff options
author | Tor Lillqvist <tml@iki.fi> | 2004-03-15 14:10:08 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2004-03-15 14:10:08 +0000 |
commit | 4d32d9024b384a926987b46516103d7b6b240fa2 (patch) | |
tree | a575f00f42f58e165341879a249287ef00e0625b /gdk-pixbuf/queryloaders.c | |
parent | ba7a95175bc33b37642a198dd6d7642c331f9002 (diff) | |
download | gtk+-4d32d9024b384a926987b46516103d7b6b240fa2.tar.gz |
[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)
Diffstat (limited to 'gdk-pixbuf/queryloaders.c')
-rw-r--r-- | gdk-pixbuf/queryloaders.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c index e2f6bfc910..21aa320eb0 100644 --- a/gdk-pixbuf/queryloaders.c +++ b/gdk-pixbuf/queryloaders.c @@ -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"); |