Make sure that the config dir exists.

Since 1a913eb we're calling realpath() on every dir and bail out if the
real path isn't available. If the game is started the first time, the
configuration dir doesn't exist at the first realpath() call and the
game errors out. Always create the configuration dir when determining
it's path.

This didn't happen on Windows because the configuration dir was created
when opening stdout.txt right after we entered main().

TODO: Sys_Mkdir() should grow at leas a little bit error handling. We're
silently ending up in -portable mode if the configuration dir couldn't
created.
This commit is contained in:
Yamagi 2020-12-30 18:45:16 +01:00
parent 983f7f6b4b
commit 8e223b2743
2 changed files with 2 additions and 2 deletions

View file

@ -483,6 +483,7 @@ Sys_GetHomeDir(void)
}
snprintf(gdir, sizeof(gdir), "%s/%s/", home, cfgdir);
Sys_Mkdir(gdir);
return gdir;
}

View file

@ -530,6 +530,7 @@ Sys_GetHomeDir(void)
}
snprintf(gdir, sizeof(gdir), "%s/%s/", profile, cfgdir);
Sys_Mkdir(gdir);
return gdir;
}
@ -726,8 +727,6 @@ Sys_RedirectStdout(void)
return;
}
Sys_Mkdir(tmp);
snprintf(path_stdout, sizeof(path_stdout), "%s/%s", dir, "stdout.txt");
snprintf(path_stderr, sizeof(path_stderr), "%s/%s", dir, "stderr.txt");