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
|
|
@ -32,9 +32,9 @@ extern unsigned char encstr[];
|
|||
extern int big_endian;
|
||||
|
||||
bool rs_write_int(FILE *savef, int c);
|
||||
bool rs_read_int(int inf, int *i);
|
||||
bool rs_read_int(FILE *inf, int *i);
|
||||
bool rs_save_file(FILE *savef);
|
||||
bool rs_restore_file(int inf);
|
||||
bool rs_restore_file(FILE *inf);
|
||||
|
||||
int md_unlink(char *file);
|
||||
bool save_file(FILE *savef);
|
||||
|
|
@ -158,7 +158,7 @@ save_file(FILE *savef)
|
|||
bool
|
||||
restore(char *file, char *envp[])
|
||||
{
|
||||
register int inf;
|
||||
FILE *inf;
|
||||
extern char **environ;
|
||||
char buf[LINELEN];
|
||||
int endian = 0x01020304;
|
||||
|
|
@ -167,7 +167,7 @@ restore(char *file, char *envp[])
|
|||
if (strcmp(file, "-r") == 0)
|
||||
file = file_name;
|
||||
|
||||
if ((inf = open(file, O_RDONLY)) < 0)
|
||||
if ((inf = fopen(file, "r")) == NULL)
|
||||
{
|
||||
if (use_savedir && errno == ENOENT)
|
||||
{
|
||||
|
|
@ -224,11 +224,11 @@ restore(char *file, char *envp[])
|
|||
{
|
||||
endwin();
|
||||
printf("Cannot restore file\n");
|
||||
close(inf);
|
||||
fclose(inf);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
close(inf);
|
||||
fclose(inf);
|
||||
|
||||
if (!wizard)
|
||||
md_unlink(file);
|
||||
|
|
@ -293,7 +293,7 @@ encwrite(char *start, unsigned long size, FILE *outf)
|
|||
*/
|
||||
|
||||
long
|
||||
encread(char *start, unsigned long size, int inf)
|
||||
encread(char *start, unsigned long size, FILE *inf)
|
||||
{
|
||||
register unsigned char *ep;
|
||||
register int rd_siz;
|
||||
|
|
@ -303,8 +303,8 @@ encread(char *start, unsigned long size, int inf)
|
|||
while (total_read < size) {
|
||||
rd_siz = ENCRBSIZ;
|
||||
rd_siz = ((size-total_read) > ENCRBSIZ) ? ENCRBSIZ : (size-total_read);
|
||||
rd_siz = read(inf,&start[total_read],rd_siz);
|
||||
if(rd_siz==-1 || rd_siz==0)
|
||||
rd_siz = fread(&start[total_read], 1, rd_siz, inf);
|
||||
if(rd_siz==0)
|
||||
break;
|
||||
total_read += rd_siz;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue