MCPcopy Create free account
hub / github.com/NetHack/NetHack / check_panic_save

Function check_panic_save

src/files.c:1311–1352  ·  view source on GitHub ↗

called if there is no save file for current character */

Source from the content-addressed store, hash-verified

1309
1310/* called if there is no save file for current character */
1311int
1312check_panic_save(void)
1313{
1314 int result = 0;
1315#ifdef CHECK_PANIC_SAVE
1316 FILE *cf;
1317 const char *savef;
1318
1319 set_error_savefile();
1320 savef = fqname(gs.SAVEF, SAVEPREFIX, 0);
1321
1322 /*
1323 * This duplicates part of docompress_file().
1324 * We don't want to start by uncompressing just to check for the
1325 * file's existence and then have to recompress it.
1326 */
1327
1328#ifdef COMPRESS_EXTENSION
1329 unsigned ln = (unsigned) (strlen(savef) + strlen(COMPRESS_EXTENSION));
1330 char *cfn = (char *) alloc(ln + 1);
1331
1332 Strcpy(cfn, savef);
1333 Strcat(cfn, COMPRESS_EXTENSION);
1334 if ((cf = fopen(cfn, RDBMODE)) != NULL) {
1335 (void) fclose(cf);
1336 result = 1;
1337 }
1338 free((genericptr_t) cfn);
1339#endif /* COMPRESS_EXTENSION */
1340
1341 if (!result) {
1342 /* maybe it has already been manually uncompressed */
1343 if ((cf = fopen(savef, RDBMODE)) != NULL) {
1344 (void) fclose(cf);
1345 result = 1;
1346 }
1347 }
1348
1349 set_savefile_name(TRUE); /* reset to normal */
1350#endif /* CHECK_PANIC_SAVE */
1351 return result;
1352}
1353
1354#if defined(SELECTSAVED)
1355

Callers 1

mainFunction · 0.85

Calls 5

set_error_savefileFunction · 0.85
fqnameFunction · 0.85
fcloseFunction · 0.85
set_savefile_nameFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected