Redirect stdout and stderr again on Windows

DF appears to redirect them itself at an inconvenient point.

Fixes #1124 (hopefully)
develop
lethosor 2017-06-30 13:29:05 -04:00
parent cc0220f030
commit 7a7f1df908
1 changed files with 11 additions and 0 deletions

@ -1504,6 +1504,17 @@ bool Core::Init()
if(errorstate)
return false;
// Re-route stdout and stderr again - DF seems to set up stdout and
// stderr.txt on Windows as of 0.43.05. Also, log before switching files to
// make it obvious what's going on if someone checks the *.txt files.
#ifndef LINUX_BUILD
// Don't do this on Linux because it will break PRINT_MODE:TEXT
fprintf(stdout, "dfhack: redirecting stdout to stdout.log (again)\n");
fprintf(stderr, "dfhack: redirecting stderr to stderr.log (again)\n");
freopen("stdout.log", "w", stdout);
freopen("stderr.log", "w", stderr);
#endif
fprintf(stderr, "DFHack build: %s\n", Version::git_description());
// find out what we are...