comparison arogue7/save.c @ 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 82b2a046d151
children f9ef86cf22b2
comparison
equal deleted inserted replaced
202:e69128d2e4c5 203:aa8e1fc62926
109 /* 109 /*
110 * write out encrpyted file (after a stat) 110 * write out encrpyted file (after a stat)
111 */ 111 */
112 if (save_file(savefd) == FALSE) { 112 if (save_file(savefd) == FALSE) {
113 msg("Cannot create save file."); 113 msg("Cannot create save file.");
114 unlink(file_name); 114 md_unlink(file_name);
115 return(FALSE); 115 return(FALSE);
116 } 116 }
117 else return(TRUE); 117 else return(TRUE);
118 } 118 }
119 119
158 fstat(savefd, &sbuf); 158 fstat(savefd, &sbuf);
159 num_to_write = strlen(version) + 1; 159 num_to_write = strlen(version) + 1;
160 num_written = ENCWRITE(version, num_to_write, savefd); 160 num_written = ENCWRITE(version, num_to_write, savefd);
161 sprintf(prbuf,"%d x %d\n", LINES, COLS); 161 sprintf(prbuf,"%d x %d\n", LINES, COLS);
162 ENCWRITE(prbuf,80,savefd); 162 ENCWRITE(prbuf,80,savefd);
163 savef = (FILE *) fdopen(savefd,"wb"); 163 savef = (FILE *) md_fdopen(savefd,"wb");
164 ret = rs_save_file(savef); 164 ret = rs_save_file(savef);
165 fclose(savef); 165 fclose(savef);
166 if (num_to_write == num_written && ret == 0) return(TRUE); 166 if (num_to_write == num_written && ret == 0) return(TRUE);
167 else return(FALSE); 167 else return(FALSE);
168 } 168 }