open savefile for reading */
| 1214 | |
| 1215 | /* open savefile for reading */ |
| 1216 | NHFILE * |
| 1217 | open_savefile(void) |
| 1218 | { |
| 1219 | const char *fq_save; |
| 1220 | NHFILE *nhfp = (NHFILE *) 0; |
| 1221 | boolean do_historical = TRUE; |
| 1222 | |
| 1223 | fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); |
| 1224 | nhfp = new_nhfile(); |
| 1225 | if (nhfp) { |
| 1226 | nhfp->ftype = NHF_SAVEFILE; |
| 1227 | nhfp->mode = READING; |
| 1228 | if (program_state.in_self_recover || do_historical) { |
| 1229 | do_historical = TRUE; /* force it */ |
| 1230 | nhUse(do_historical); |
| 1231 | nhfp->structlevel = TRUE; |
| 1232 | nhfp->fieldlevel = FALSE; |
| 1233 | nhfp->addinfo = FALSE; |
| 1234 | nhfp->style.deflt = FALSE; |
| 1235 | nhfp->style.binary = TRUE; |
| 1236 | nhfp->fnidx = historical; |
| 1237 | nhfp->fd = -1; |
| 1238 | nhfp->fpdef = (FILE *) 0; |
| 1239 | #ifdef SAVEFILE_DEBUGGING |
| 1240 | nhfp->fplog = fopen("open-savefile.log", "w"); |
| 1241 | #endif |
| 1242 | } |
| 1243 | #ifdef MACOS9 |
| 1244 | nhfp->fd = macopen(fq_save, O_RDONLY | O_BINARY, SAVE_TYPE); |
| 1245 | #else |
| 1246 | nhfp->fd = open(fq_save, O_RDONLY | O_BINARY, 0); |
| 1247 | #endif |
| 1248 | #if defined(MSDOS) || defined(WIN32) |
| 1249 | if (nhfp->fd >= 0) |
| 1250 | (void) setmode(nhfp->fd, O_BINARY); |
| 1251 | #endif |
| 1252 | } |
| 1253 | nhfp = viable_nhfile(nhfp); |
| 1254 | return nhfp; |
| 1255 | } |
| 1256 | |
| 1257 | /* delete savefile */ |
| 1258 | int |
no test coverage detected