Mercurial > hg > early-roguelike
diff rogue4/mach_dep.c @ 279:d3968e9cb98d
Use C stdio functions for score files and save files.
Switching from Unix file descriptor operations to C standard FILE*
functions will reduce portability problems.
author | John "Elwin" Edwards |
---|---|
date | Fri, 15 Sep 2017 19:57:54 -0400 |
parents | 1b73a8641b37 |
children | 6376b514a30b |
line wrap: on
line diff
--- a/rogue4/mach_dep.c Sun Sep 10 17:30:13 2017 -0400 +++ b/rogue4/mach_dep.c Fri Sep 15 19:57:54 2017 -0400 @@ -37,6 +37,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <string.h> +#include <errno.h> #include "rogue.h" int num_checks; /* times we've gone over in checkout() */ @@ -80,9 +81,12 @@ open_score(void) { #ifdef SCOREFILE - fd = open(SCOREFILE, O_RDWR | O_CREAT, 0666 ); + score_file = fopen(SCOREFILE, "r+"); + if ((score_file == NULL) && (errno == ENOENT)) { + score_file = fopen(SCOREFILE, "w+"); + } #else - fd = -1; + score_file = NULL; #endif if (!use_savedir) md_normaluser(); @@ -93,9 +97,9 @@ open_log(void) { #ifdef LOGFILE - lfd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT, 0666); + log_file = fopen(LOGFILE, "a"); #else - lfd = -1; + log_file = NULL; #endif return; }