New function status_inc() to increment params->status
This commit is contained in:
parent
068c665c49
commit
7afe29c487
3 changed files with 133 additions and 123 deletions
|
@ -1023,3 +1023,51 @@ const char *status_to_name(const photorec_status_t status)
|
|||
return "STATUS_QUIT";
|
||||
}
|
||||
}
|
||||
|
||||
void status_inc(struct ph_param *params, const struct ph_options *options)
|
||||
{
|
||||
params->offset=-1;
|
||||
switch(params->status)
|
||||
{
|
||||
case STATUS_UNFORMAT:
|
||||
params->status=STATUS_FIND_OFFSET;
|
||||
break;
|
||||
case STATUS_FIND_OFFSET:
|
||||
params->status=(options->mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
params->file_nbr=0;
|
||||
break;
|
||||
case STATUS_EXT2_ON:
|
||||
if(options->paranoid>1)
|
||||
params->status=STATUS_EXT2_ON_BF;
|
||||
else if(options->paranoid==1 && options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_ON_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_ON_BF:
|
||||
if(options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_ON_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_OFF:
|
||||
if(options->paranoid>1)
|
||||
params->status=STATUS_EXT2_OFF_BF;
|
||||
else if(options->paranoid==1 && options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_OFF_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_OFF_BF:
|
||||
if(options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_OFF_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
default:
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ void set_filename(file_recovery_t *file_recovery, struct ph_param *params);
|
|||
uint64_t set_search_start(struct ph_param *params, alloc_data_t **new_current_search_space, alloc_data_t *list_search_space);
|
||||
void params_reset(struct ph_param *params, const struct ph_options *options);
|
||||
const char *status_to_name(const photorec_status_t status);
|
||||
void status_inc(struct ph_param *params, const struct ph_options *options);
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
#endif
|
||||
|
|
79
src/phrecn.c
79
src/phrecn.c
|
@ -844,12 +844,13 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
|
|||
wattroff(stdscr, A_REVERSE);
|
||||
wrefresh(stdscr);
|
||||
#endif
|
||||
if(params->status==STATUS_UNFORMAT)
|
||||
switch(params->status)
|
||||
{
|
||||
case STATUS_UNFORMAT:
|
||||
ind_stop=fat_unformat(params, options, list_search_space);
|
||||
params->blocksize=blocksize_is_known;
|
||||
}
|
||||
else if(params->status==STATUS_FIND_OFFSET)
|
||||
break;
|
||||
case STATUS_FIND_OFFSET:
|
||||
{
|
||||
uint64_t start_offset=0;
|
||||
if(blocksize_is_known>0)
|
||||
|
@ -869,17 +870,20 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
|
|||
#endif
|
||||
update_blocksize(params->blocksize, list_search_space, start_offset);
|
||||
}
|
||||
else if(params->status==STATUS_EXT2_ON_BF || params->status==STATUS_EXT2_OFF_BF)
|
||||
{
|
||||
break;
|
||||
case STATUS_EXT2_ON_BF:
|
||||
case STATUS_EXT2_OFF_BF:
|
||||
ind_stop=photorec_bf(params, options, list_search_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default:
|
||||
ind_stop=photorec_aux(params, options, list_search_space);
|
||||
break;
|
||||
}
|
||||
session_save(list_search_space, params, options);
|
||||
|
||||
if(ind_stop==PSTATUS_ENOSPC)
|
||||
switch(ind_stop)
|
||||
{
|
||||
case PSTATUS_ENOSPC:
|
||||
{ /* no more space */
|
||||
#ifdef HAVE_NCURSES
|
||||
char *dst;
|
||||
|
@ -910,13 +914,12 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
|
|||
params->status=STATUS_QUIT;
|
||||
#endif
|
||||
}
|
||||
else if(ind_stop==PSTATUS_EACCES)
|
||||
{
|
||||
break;
|
||||
case PSTATUS_EACCES:
|
||||
if(interface_cannot_create_file()!=0)
|
||||
params->status=STATUS_QUIT;
|
||||
}
|
||||
else if(ind_stop==PSTATUS_STOP)
|
||||
{
|
||||
break;
|
||||
case PSTATUS_STOP:
|
||||
if(session_save(list_search_space, params, options) < 0)
|
||||
{
|
||||
/* Failed to save the session! */
|
||||
|
@ -932,54 +935,12 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
|
|||
params->status=STATUS_QUIT;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(ind_stop==PSTATUS_OK)
|
||||
{
|
||||
params->offset=-1;
|
||||
switch(params->status)
|
||||
{
|
||||
case STATUS_UNFORMAT:
|
||||
params->status=STATUS_FIND_OFFSET;
|
||||
break;
|
||||
case STATUS_FIND_OFFSET:
|
||||
params->status=(options->mode_ext2>0?STATUS_EXT2_ON:STATUS_EXT2_OFF);
|
||||
params->file_nbr=0;
|
||||
break;
|
||||
case STATUS_EXT2_ON:
|
||||
if(options->paranoid>1)
|
||||
params->status=STATUS_EXT2_ON_BF;
|
||||
else if(options->paranoid==1 && options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_ON_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_ON_BF:
|
||||
if(options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_ON_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_OFF:
|
||||
if(options->paranoid>1)
|
||||
params->status=STATUS_EXT2_OFF_BF;
|
||||
else if(options->paranoid==1 && options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_OFF_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
case STATUS_EXT2_OFF_BF:
|
||||
if(options->keep_corrupted_file>0)
|
||||
params->status=STATUS_EXT2_OFF_SAVE_EVERYTHING;
|
||||
else
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
default:
|
||||
params->status=STATUS_QUIT;
|
||||
break;
|
||||
}
|
||||
case PSTATUS_OK:
|
||||
status_inc(params, options);
|
||||
if(params->status==STATUS_QUIT)
|
||||
unlink("photorec.ses");
|
||||
break;
|
||||
}
|
||||
{
|
||||
const time_t current_time=time(NULL);
|
||||
|
|
Loading…
Reference in a new issue