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 #ifdef LOGMESSAGES
extern FILE *logstream; extern FILE *logstream;
extern FILE *crashstream;
extern char logfilename[1024]; extern char logfilename[1024];
#endif #endif

View File

@ -52,7 +52,6 @@ extern int SDL_main(int argc, char *argv[]);
#ifdef LOGMESSAGES #ifdef LOGMESSAGES
FILE *logstream = NULL; FILE *logstream = NULL;
FILE *crashstream = NULL;
char logfilename[1024]; char logfilename[1024];
#endif #endif
@ -250,9 +249,6 @@ int main(int argc, char **argv)
// startup SRB2 // startup SRB2
CONS_Printf("Setting up SRB2...\n"); CONS_Printf("Setting up SRB2...\n");
D_SRB2Main(); D_SRB2Main();
crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at");
#ifdef LOGMESSAGES #ifdef LOGMESSAGES
if (!M_CheckParm("-nolog")) if (!M_CheckParm("-nolog"))
CONS_Printf("Logfile: %s\n", logfilename); 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 *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. const char *error2 = "(Or find crash-log.txt in your SRB2 directory.)\n"; // Shown only to stderr.
if (!crashstream) fd = open(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), O_CREAT|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR);
crashstream = fopen(va("%s" PATHSEP "%s", srb2home, "crash-log.txt"), "at");
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"); 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); time(&rawtime);
timeinfo = localtime(&rawtime); timeinfo = localtime(&rawtime);