mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 14:30:48 +00:00
Write stdout.txt into the same dir as the config when running portable.
This commit is contained in:
parent
7d08906bca
commit
383f667c46
1 changed files with 16 additions and 11 deletions
|
@ -649,26 +649,33 @@ void
|
||||||
Sys_RedirectStdout(void)
|
Sys_RedirectStdout(void)
|
||||||
{
|
{
|
||||||
char *cur;
|
char *cur;
|
||||||
char *home;
|
|
||||||
char *old;
|
char *old;
|
||||||
|
char dir[MAX_OSPATH];
|
||||||
char path_stdout[MAX_OSPATH];
|
char path_stdout[MAX_OSPATH];
|
||||||
char path_stderr[MAX_OSPATH];
|
char path_stderr[MAX_OSPATH];
|
||||||
|
const char *tmp;
|
||||||
|
|
||||||
home = Sys_GetHomeDir();
|
if (is_portable) {
|
||||||
|
tmp = Sys_GetBinaryDir();
|
||||||
|
Q_strlcpy(dir, tmp, sizeof(dir));
|
||||||
|
} else {
|
||||||
|
tmp = Sys_GetHomeDir();
|
||||||
|
Q_strlcpy(dir, tmp, sizeof(dir));
|
||||||
|
}
|
||||||
|
|
||||||
if (home == NULL)
|
if (dir == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur = old = home;
|
cur = old = dir;
|
||||||
|
|
||||||
while (cur != NULL)
|
while (cur != NULL)
|
||||||
{
|
{
|
||||||
if ((cur - old) > 1)
|
if ((cur - old) > 1)
|
||||||
{
|
{
|
||||||
*cur = '\0';
|
*cur = '\0';
|
||||||
Sys_Mkdir(home);
|
Sys_Mkdir(dir);
|
||||||
*cur = '/';
|
*cur = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,8 +683,8 @@ Sys_RedirectStdout(void)
|
||||||
cur = strchr(old + 1, '/');
|
cur = strchr(old + 1, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path_stdout, sizeof(path_stdout), "%s/%s", home, "stdout.txt");
|
snprintf(path_stdout, sizeof(path_stdout), "%s/%s", dir, "stdout.txt");
|
||||||
snprintf(path_stderr, sizeof(path_stderr), "%s/%s", home, "stderr.txt");
|
snprintf(path_stderr, sizeof(path_stderr), "%s/%s", dir, "stderr.txt");
|
||||||
|
|
||||||
freopen(path_stdout, "w", stdout);
|
freopen(path_stdout, "w", stdout);
|
||||||
freopen(path_stderr, "w", stderr);
|
freopen(path_stderr, "w", stderr);
|
||||||
|
@ -758,15 +765,13 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
/* Are we portable? */
|
/* Are we portable? */
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-portable") == 0) {
|
if (strcmp(argv[i], "-portable") == 0) {
|
||||||
portable = true;
|
is_portable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to redirect stdout before anything happens. */
|
/* Need to redirect stdout before anything happens. */
|
||||||
#ifndef DEDICATED_ONLY
|
#ifndef DEDICATED_ONLY
|
||||||
if (!is_portable) {
|
Sys_RedirectStdout();
|
||||||
Sys_RedirectStdout;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("Yamagi Quake II v%s\n", YQ2VERSION);
|
printf("Yamagi Quake II v%s\n", YQ2VERSION);
|
||||||
|
|
Loading…
Reference in a new issue