Use file descriptors and ditch file streams, for now.

This commit is contained in:
GoldenTails 2020-12-03 17:08:40 -06:00
parent 4016a2e062
commit 5108f1f57b
3 changed files with 2 additions and 15 deletions

View File

@ -118,7 +118,6 @@
#ifdef LOGMESSAGES
extern FILE *logstream;
extern FILE *crashstream;
extern char logfilename[1024];
#endif

View File

@ -52,7 +52,6 @@ extern int SDL_main(int argc, char *argv[]);
#ifdef LOGMESSAGES
FILE *logstream = NULL;
FILE *crashstream = NULL;
char logfilename[1024];
#endif
@ -250,9 +249,6 @@ int main(int argc, char **argv)
// startup SRB2
CONS_Printf("Setting up SRB2...\n");
D_SRB2Main();
crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at");
#ifdef LOGMESSAGES
if (!M_CheckParm("-nolog"))
CONS_Printf("Logfile: %s\n", logfilename);

View File

@ -264,18 +264,10 @@ static void write_backtrace(INT32 signal)
const char *error = "An error occurred within SRB2! Send this stack trace to someone who can help!\n";
const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr.
if (!crashstream)
crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at");
fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR);
if (!crashstream)
if (fd == -1)
I_OutputMsg("\nWARNING: Couldn't open crash log for writing! Make sure your permissions are correct. Please save the below report!\n");
else
{
fd = fileno(crashstream);
if (fd == -1)
fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND);
}
time(&rawtime);
timeinfo = localtime(&rawtime);