From b96d247db3ece42e11d503c54af301ddf52d424e Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Thu, 21 Jun 2012 09:26:37 +0200 Subject: [PATCH] Create homedir before redirecting stdout and stderr --- src/windows/system.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/windows/system.c b/src/windows/system.c index caed8d74..d245d0e1 100644 --- a/src/windows/system.c +++ b/src/windows/system.c @@ -695,7 +695,9 @@ Sys_GetHomeDir(void) void Sys_RedirectStdout(void) { + char *cur; char *home; + char *old; char path_stdout[MAX_OSPATH]; char path_stderr[MAX_OSPATH]; @@ -711,6 +713,21 @@ Sys_RedirectStdout(void) return; } + cur = old = home; + + while (cur != NULL) + { + if ((cur - old) > 1) + { + *cur = '\0'; + Sys_Mkdir(home); + *cur = '/'; + } + + old = cur; + cur = strchr(old + 1, '/'); + } + snprintf(path_stdout, sizeof(path_stdout), "%s/%s", home, "stdout.txt"); snprintf(path_stderr, sizeof(path_stderr), "%s/%s", home, "stderr.txt");