Create homedir before redirecting stdout and stderr

This commit is contained in:
Yamagi Burmeister 2012-06-21 09:26:37 +02:00
parent 403c69d6c1
commit b96d247db3

View file

@ -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");