Skip to content

Commit

Permalink
Correct for widechar on Windows
Browse files Browse the repository at this point in the history
Commit migrated from mono/mono@9100c24
  • Loading branch information
nealef committed Jun 3, 2016
1 parent c5bd789 commit 5e53a23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/mono/mono/utils/mono-log-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/utils/mono-log-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static FILE *logFile = NULL;
static void *logUserData = NULL;
static char logFileName[] = L".//mono.log";
static wchar_t *logFileName = L".//mono.log";

/**
* mapSyslogLevel:
Expand Down Expand Up @@ -65,7 +65,7 @@ mapLogFileLevel(GLogLevelFlags level)
void
mono_log_open_syslog(const char *ident, void *userData)
{
logFile = fopen(logFileName, "w");
logFile = _wfopen(logFileName, L"w");
if (logFile == NULL) {
g_warning("opening of log file %s failed with %s",
strerror(errno));
Expand Down

0 comments on commit 5e53a23

Please sign in to comment.