2.11.2
[platform/upstream/glib.git] / gmodule / gmodule-win32.c
index 882ee7b..bf63091 100644 (file)
@@ -62,8 +62,21 @@ _g_module_open (const gchar *file_name,
   cygwin_conv_to_win32_path(file_name, tmp);
   file_name = tmp;
 #endif
+  if (G_WIN32_HAVE_WIDECHAR_API ())
+    {
+      wchar_t *wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
   
-  handle = LoadLibrary (file_name);
+      handle = LoadLibraryW (wfilename);
+      g_free (wfilename);
+    }
+  else
+    {
+      gchar *cp_filename = g_locale_from_utf8 (file_name, -1, NULL, NULL, NULL);
+
+      handle = LoadLibraryA (cp_filename);
+      g_free (cp_filename);
+    }
+      
   if (!handle)
     set_error ();
 
@@ -230,14 +243,28 @@ _g_module_build_path (const gchar *directory,
   if (directory && *directory)
     if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
       return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, NULL);
+#ifdef G_WITH_CYGWIN
+    else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
+    else
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, "cyg", module_name, ".dll", NULL);
+#else
     else if (strncmp (module_name, "lib", 3) == 0)
       return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
     else
       return g_strconcat (directory, G_DIR_SEPARATOR_S, "lib", module_name, ".dll", NULL);
+#endif
   else if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
     return g_strdup (module_name);
+#ifdef G_WITH_CYGWIN
+  else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+    return g_strconcat (module_name, ".dll", NULL);
+  else
+    return g_strconcat ("cyg", module_name, ".dll", NULL);
+#else
   else if (strncmp (module_name, "lib", 3) == 0)
     return g_strconcat (module_name, ".dll", NULL);
   else
     return g_strconcat ("lib", module_name, ".dll", NULL);
+#endif
 }