From 5108f1f57b805f7517e703f8c4b973d8489c3aa7 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Thu, 3 Dec 2020 17:08:40 -0600 Subject: [PATCH] Use file descriptors and ditch file streams, for now. --- src/doomdef.h | 1 - src/sdl/i_main.c | 4 ---- src/sdl/i_system.c | 12 ++---------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e1cda6f42..52abc9597 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -118,7 +118,6 @@ #ifdef LOGMESSAGES extern FILE *logstream; -extern FILE *crashstream; extern char logfilename[1024]; #endif diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 03783d1ef..1dee379c0 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -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); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 528d495c7..7c870c0c7 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -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);