Correct for widechar on Windows
[mono.git] / mono / utils / mono-log-common.c
index 39f68ca160769e13e6b330913de88a88bf5cb417..e068bfd0447b30970b321ea831c8c8c22cff2670 100644 (file)
@@ -69,10 +69,19 @@ mono_log_open_logfile(const char *path, void *userData)
        if (path == NULL) {
                logFile = stdout;
        } else {
+#ifndef HOST_WIN32
                logFile = fopen(path, "w");
+#else
+               guinchar2 *wPath = g_utf8_to_utf16(path, -1, 0, 0, 0);
+               if (wPath != NULL) {
+                       logFile = _wfopen((wchar_t *) wPath, L"w");
+                       g_free (wPath);
+               }
+#endif
                if (logFile == NULL) {
                        g_warning("opening of log file %s failed with %s - defaulting to stdout", 
                                  path, strerror(errno));
+                       logFile = stdout;
                }
        }
        logUserData = userData;