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:
John "Elwin" Edwards 2017-09-15 19:57:54 -04:00
parent f8d1f422c8
commit c661fd79d4
33 changed files with 426 additions and 439 deletions

View file

@ -191,7 +191,7 @@ save_file(FILE *savef)
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 @@ restore(char *file, char **envp)
#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 @@ restore(char *file, char **envp)
return FALSE;
}
fstat(inf, &sbuf2);
stat(file, &sbuf2);
encread(&slines,sizeof(slines),inf);
encread(&scols,sizeof(scols),inf);
@ -279,11 +280,11 @@ restore(char *file, char **envp)
}
#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");