diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-09-03 22:03:13 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-03 13:29:03 -0700 |
commit | 6af67f541d104e1cce381b14da53e5b1f7fe58fc (patch) | |
tree | cd12202033db01f4e4131bbb8d88b014475046de /core | |
parent | c47b6b672f20638448badd6d681644dcff69c0eb (diff) | |
download | subsurface-6af67f541d104e1cce381b14da53e5b1f7fe58fc.tar.gz |
core/windows.c: write logs to the user path
Writing logs to the path where the executable is located,
might not be possible if the current user doesn't have
permissions to write there.
Obtain the user path and write the log files to the
user path instead - e.g.:
c:\users\myuser\appdata\roaming\subsurface\subsurface_*.log
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/windows.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/windows.c b/core/windows.c index f1c95fff1..77b7f5755 100644 --- a/core/windows.c +++ b/core/windows.c @@ -424,8 +424,14 @@ void subsurface_console_init(void) console_desc.err = freopen("CON", "w", stderr); } else { verbose = 1; /* set the verbose level to '1' */ - console_desc.out = freopen("subsurface_out.log", "w", stdout); - console_desc.err = freopen("subsurface_err.log", "w", stderr); + wchar_t *wpath_out = system_default_path_append(L"subsurface_out.log"); + wchar_t *wpath_err = system_default_path_append(L"subsurface_err.log"); + if (wpath_out && wpath_err) { + console_desc.out = _wfreopen(wpath_out, L"w", stdout); + console_desc.err = _wfreopen(wpath_err, L"w", stderr); + } + free((void *)wpath_out); + free((void *)wpath_err); } puts(""); /* add an empty line */ |