Mercurial > hg > early-roguelike
changeset 203:aa8e1fc62926
Advanced Rogue 7: add and use more md_ functions.
md_fileno() and md_fdopen() are now included. I still hope to rewrite
everything to use FILE *'s.
author | John "Elwin" Edwards |
---|---|
date | Thu, 13 Aug 2015 07:38:57 -0400 |
parents | e69128d2e4c5 |
children | 4b1999ac91cf |
files | arogue7/mdport.c arogue7/rogue.h arogue7/save.c arogue7/state.c |
diffstat | 4 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/arogue7/mdport.c Wed Aug 12 17:03:15 2015 -0400 +++ b/arogue7/mdport.c Thu Aug 13 07:38:57 2015 -0400 @@ -175,6 +175,26 @@ #endif } +FILE * +md_fdopen(int fd, char *mode) +{ +#ifdef _WIN32 + return( _fdopen(fd, mode) ); +#else + return( fdopen(fd, mode) ); +#endif +} + +int +md_fileno(FILE *fp) +{ +#ifdef _WIN32 + return( _fileno(fp) ); +#else + return( fileno(fp) ); +#endif +} + int md_creat(char *file, int mode) {
--- a/arogue7/rogue.h Wed Aug 12 17:03:15 2015 -0400 +++ b/arogue7/rogue.h Thu Aug 13 07:38:57 2015 -0400 @@ -1303,3 +1303,5 @@ extern int demoncnt, fusecnt, between, chance; #define CCHAR(x) ( (char) (x & A_CHARTEXT) ) extern char *md_gethostname(), *md_getusername(), *md_gethomedir(), *md_getroguedir(), *md_crypt(); +extern FILE * md_fdopen(int fd, char *mode); +extern int md_fileno(FILE *fp);
--- a/arogue7/save.c Wed Aug 12 17:03:15 2015 -0400 +++ b/arogue7/save.c Thu Aug 13 07:38:57 2015 -0400 @@ -111,7 +111,7 @@ */ if (save_file(savefd) == FALSE) { msg("Cannot create save file."); - unlink(file_name); + md_unlink(file_name); return(FALSE); } else return(TRUE); @@ -160,7 +160,7 @@ num_written = ENCWRITE(version, num_to_write, savefd); sprintf(prbuf,"%d x %d\n", LINES, COLS); ENCWRITE(prbuf,80,savefd); - savef = (FILE *) fdopen(savefd,"wb"); + savef = (FILE *) md_fdopen(savefd,"wb"); ret = rs_save_file(savef); fclose(savef); if (num_to_write == num_written && ret == 0) return(TRUE);