Skip to content

Commit 00cf411

Browse files
committed
Handle Unicode path when reopening log file on Windows
1 parent b44638c commit 00cf411

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/util.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,15 @@ void LogPrintStr(const std::string &str)
294294
// reopen the log file, if requested
295295
if (fReopenDebugLog) {
296296
fReopenDebugLog = false;
297+
297298
fs::path pathDebug = GetDataDir() / "debug.log";
298-
if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL)
299-
setbuf(fileout, NULL); // unbuffered
299+
FILE* new_fileout = fsbridge::fopen(pathDebug, "a");
300+
301+
if (new_fileout) {
302+
setbuf(new_fileout, NULL); // unbuffered
303+
fclose(fileout);
304+
fileout = new_fileout;
305+
}
300306
}
301307

302308
// Debug print useful for profiling

0 commit comments

Comments
 (0)