summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-07-14 10:46:04 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-07-14 10:46:04 +0200
commitecfe21affdc6b5b6cc787b9c5ef3a2a05f264fd9 (patch)
tree941d13aa05e0ab3b5ac2dfa8c2b6e834f5eb2253
parente27faf2a246b5dbb3fbbd7b65c1343d96c9fc9b7 (diff)
PhotoRec: modify how FileOpts settings are saved in session file
-rw-r--r--src/sessionp.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/sessionp.c b/src/sessionp.c
index 4d8f75e..a3ff8c4 100644
--- a/src/sessionp.c
+++ b/src/sessionp.c
@@ -172,6 +172,9 @@ int session_save(alloc_data_t *list_free_space, struct ph_param *params, const
struct td_list_head *free_walker = NULL;
unsigned int i;
const file_enable_t *files_enable=options->list_file_format;
+ unsigned int disable=0;
+ unsigned int enable=0;
+ unsigned int enable_by_default=0;
if(options->verbose>1)
{
log_trace("session_save\n");
@@ -180,9 +183,50 @@ int session_save(alloc_data_t *list_free_space, struct ph_param *params, const
(unsigned int)time(NULL), params->disk->device, params->disk->arch->part_name_option, params->partition->order, params->blocksize);
for(i=0;files_enable[i].file_hint!=NULL;i++)
{
- if(files_enable[i].file_hint->extension!=NULL && files_enable[i].file_hint->extension[0]!='\0')
+ if(files_enable[i].enable==0)
+ disable++;
+ else
+ enable++;
+ if(files_enable[i].enable==files_enable[i].file_hint->enable_by_default)
+ enable_by_default++;
+ }
+ if(enable_by_default >= disable && enable_by_default >= enable)
+ {
+ for(i=0;files_enable[i].file_hint!=NULL;i++)
+ {
+ if(files_enable[i].enable!=files_enable[i].file_hint->enable_by_default &&
+ files_enable[i].file_hint->extension!=NULL &&
+ files_enable[i].file_hint->extension[0]!='\0')
+ {
+ fprintf(f_session,"%s,%s,", files_enable[i].file_hint->extension,
+ (files_enable[i].enable!=0?"enable":"disable"));
+ }
+ }
+ }
+ else if(enable > disable)
+ {
+ fprintf(f_session,"everything,enable,");
+ for(i=0;files_enable[i].file_hint!=NULL;i++)
+ {
+ if(files_enable[i].enable==0 &&
+ files_enable[i].file_hint->extension!=NULL &&
+ files_enable[i].file_hint->extension[0]!='\0')
+ {
+ fprintf(f_session,"%s,disable,", files_enable[i].file_hint->extension);
+ }
+ }
+ }
+ else
+ {
+ fprintf(f_session,"everything,disable,");
+ for(i=0;files_enable[i].file_hint!=NULL;i++)
{
- fprintf(f_session,"%s,%s,",files_enable[i].file_hint->extension,(files_enable[i].enable!=0?"enable":"disable"));
+ if(files_enable[i].enable!=0 &&
+ files_enable[i].file_hint->extension!=NULL &&
+ files_enable[i].file_hint->extension[0]!='\0')
+ {
+ fprintf(f_session,"%s,enable,", files_enable[i].file_hint->extension);
+ }
}
}
/* Save options */