diff options
author | Christophe Grenier <[email protected]> | 2025-04-04 17:55:46 +0200 |
---|---|---|
committer | Christophe Grenier <[email protected]> | 2025-04-04 17:55:46 +0200 |
commit | 544ecfea8ced026f474bf72c866fedabbd03f65c (patch) | |
tree | 0ea8e1e327fdfc8dc98d1fa0a0348c782038ba04 | |
parent | 12d9d97bba3299cf140964d25b897383369dec5c (diff) |
src/file_maxis.c: PhotoRec - recover Maxis games (ie. The Sims) .maxis files
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/file_list.c | 6 | ||||
-rw-r--r-- | src/file_maxis.c | 66 |
3 files changed, 73 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 612e8671..36217794 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -232,6 +232,7 @@ file_C = filegen.c \ file_m2ts.c \ file_mat.c \ file_max.c \ + file_maxis.c \ file_mb.c \ file_mcd.c \ file_mdb.c \ diff --git a/src/file_list.c b/src/file_list.c index e5e40fa6..080d84bc 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -577,6 +577,9 @@ extern const file_hint_t file_hint_mat; #if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_max) extern const file_hint_t file_hint_max; #endif +#if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_maxis) +extern const file_hint_t file_hint_maxis; +#endif #if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_mb) extern const file_hint_t file_hint_mb; #endif @@ -1630,6 +1633,9 @@ file_enable_t array_file_enable[]= #if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_max) { .enable=0, .file_hint=&file_hint_max }, #endif +#if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_maxis) + { .enable=0, .file_hint=&file_hint_maxis }, +#endif #if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_mb) { .enable=0, .file_hint=&file_hint_mb }, #endif diff --git a/src/file_maxis.c b/src/file_maxis.c new file mode 100644 index 00000000..4e84cca4 --- /dev/null +++ b/src/file_maxis.c @@ -0,0 +1,66 @@ +/* + + File: file_maxis.c + + Copyright (C) 2024 Christophe GRENIER <[email protected]> + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write the Free Software Foundation, Inc., 51 + Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + */ + +#if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_maxis) +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#include <stdio.h> +#include "types.h" +#include "filegen.h" + +/*@ requires valid_register_header_check(file_stat); */ +static void register_header_check_maxis(file_stat_t *file_stat); + +const file_hint_t file_hint_maxis= { + .extension="maxis", + .description="Maxis games (ie. The Sims)", + .max_filesize=PHOTOREC_MAX_FILE_SIZE, + .recover=1, + .enable_by_default=1, + .register_header_check=®ister_header_check_maxis +}; + +/*@ + @ requires separation: \separated(&file_hint_maxis, buffer+(..), file_recovery, file_recovery_new); + @ requires valid_header_check_param(buffer, buffer_size, safe_header_only, file_recovery, file_recovery_new); + @ ensures valid_header_check_result(\result, file_recovery_new); + @ assigns *file_recovery_new; + @*/ +static int header_check_maxis(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) +{ + if(buffer[5]!=0 || buffer[6]!= 0 || buffer[7]!= 0) + return 0; + reset_file_recovery(file_recovery_new); + file_recovery_new->extension=file_hint_maxis.extension; + file_recovery_new->min_filesize=0x60; + return 1; +} + +static void register_header_check_maxis(file_stat_t *file_stat) +{ + register_header_check(0, "DBPF", 4, &header_check_maxis, file_stat); +} +#endif |