get list of saved games owned by current user */
| 1396 | |
| 1397 | /* get list of saved games owned by current user */ |
| 1398 | char ** |
| 1399 | get_saved_games(void) |
| 1400 | { |
| 1401 | char **result = NULL; |
| 1402 | #if defined(SELECTSAVED) |
| 1403 | #if defined(WIN32) || defined(UNIX) |
| 1404 | int n; |
| 1405 | #endif |
| 1406 | int j = 0; |
| 1407 | |
| 1408 | #ifdef WIN32 |
| 1409 | { |
| 1410 | char *foundfile; |
| 1411 | const char *fq_save; |
| 1412 | #if 0 |
| 1413 | const char *fq_new_save; |
| 1414 | const char *fq_old_save; |
| 1415 | #endif |
| 1416 | char **files = 0; |
| 1417 | int i, count_failures = 0; |
| 1418 | |
| 1419 | Strcpy(svp.plname, "*"); |
| 1420 | set_savefile_name(FALSE); |
| 1421 | #if defined(ZLIB_COMP) |
| 1422 | Strcat(gs.SAVEF, COMPRESS_EXTENSION); |
| 1423 | #endif |
| 1424 | fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); |
| 1425 | |
| 1426 | n = 0; |
| 1427 | foundfile = foundfile_buffer(); |
| 1428 | if (findfirst((char *) fq_save)) { |
| 1429 | do { |
| 1430 | ++n; |
| 1431 | } while (findnext()); |
| 1432 | } |
| 1433 | |
| 1434 | if (n > 0) { |
| 1435 | files = (char **) alloc((n + 1) * sizeof (char *)); /* at most */ |
| 1436 | (void) memset((genericptr_t) files, 0, (n + 1) * sizeof (char *)); |
| 1437 | if (findfirst((char *) fq_save)) { |
| 1438 | i = 0; |
| 1439 | do { |
| 1440 | files[i++] = dupstr(foundfile); |
| 1441 | } while (findnext()); |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | if (n > 0) { |
| 1446 | result = (char **) alloc((n + 1) * sizeof (char *)); /* at most */ |
| 1447 | (void) memset((genericptr_t) result, 0, (n + 1) * sizeof (char *)); |
| 1448 | for(i = 0; i < n; i++) { |
| 1449 | char *r; |
| 1450 | r = plname_from_file(files[i], SUPPRESS_WAITSYNCH_PERFILE); |
| 1451 | |
| 1452 | if (r) { |
| 1453 | /* this renaming of the savefile is not compatible |
| 1454 | * with 1f36b98b, 'selectsaved' extension from |
| 1455 | * Oct 10, 2024. Disable the renaming for the time |
no test coverage detected