Mercurial > hg > early-roguelike
diff srogue/save.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 | 3d4252fa2ed3 |
children | 70aa5808c782 |
line wrap: on
line diff
--- a/srogue/save.c Sun Sep 10 17:30:13 2017 -0400 +++ b/srogue/save.c Fri Sep 15 19:57:54 2017 -0400 @@ -191,7 +191,7 @@ bool restore(char *file, char **envp) { - register int inf, pid; + register int pid; int ret_status; #ifndef _AIX extern char **environ; @@ -199,11 +199,12 @@ #ifdef __DJGPP__ /* st_ino w/ DJGPP under WinXP broken */ _djstat_flags |= _STAT_INODE; /* so turn off computing it for now */ #endif + FILE *inf; char buf[LINLEN]; STAT sbuf2; int slines, scols; - if ((inf = open(file, O_RDONLY)) < 0) { + if ((inf = fopen(file, "r")) == NULL) { if (use_savedir && errno == ENOENT) return TRUE; else { @@ -219,7 +220,7 @@ return FALSE; } - fstat(inf, &sbuf2); + stat(file, &sbuf2); encread(&slines,sizeof(slines),inf); encread(&scols,sizeof(scols),inf); @@ -279,11 +280,11 @@ } #if defined(__CYGWIN__) || defined(__DJGPP__) - close(inf); + fclose(inf); #endif if (!wizard) { - if (md_unlink_open_file(file, md_fdopen(inf, "r")) < 0) + if (md_unlink_open_file(file, inf) < 0) { endwin(); printf("Cannot unlink file\n");