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.
This commit is contained in:
parent
f8d1f422c8
commit
c661fd79d4
33 changed files with 426 additions and 439 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include "rogue.h"
|
||||
|
||||
|
|
@ -37,7 +38,7 @@
|
|||
char *roguehome(void);
|
||||
void open_records(void);
|
||||
|
||||
extern int scorefd;
|
||||
extern FILE *scoreboard;
|
||||
extern FILE *logfile;
|
||||
|
||||
int
|
||||
|
|
@ -480,8 +481,11 @@ roguehome(void)
|
|||
void
|
||||
open_records(void)
|
||||
{
|
||||
if (scorefd < 0)
|
||||
scorefd = open(scorefile, O_RDWR | O_CREAT, 0666);
|
||||
if (scoreboard == NULL)
|
||||
scoreboard = fopen(scorefile, "r+");
|
||||
if (scoreboard == NULL && errno == ENOENT) {
|
||||
scoreboard = fopen(scorefile, "w+");
|
||||
}
|
||||
#ifdef LOGFILE
|
||||
if (logfile == NULL)
|
||||
logfile = fopen(LOGFILE, "a");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue