Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #17 #21

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/fat_unformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ static pstatus_t fat_unformat_aux(struct ph_param *params, const struct ph_optio
const unsigned int cluster_size=params->blocksize;
const unsigned int read_size=(cluster_size>65536?cluster_size:65536);
alloc_data_t *current_search_space;
file_recovery_t file_recovery;
disk_t *disk=params->disk;
const partition_t *partition=params->partition;
const unsigned long int no_of_cluster=(partition->part_size - start_data) / cluster_size;
Expand All @@ -224,8 +223,6 @@ static pstatus_t fat_unformat_aux(struct ph_param *params, const struct ph_optio
#ifdef HAVE_NCURSES
aff_copy(stdscr);
#endif
reset_file_recovery(&file_recovery);
file_recovery.blocksize=cluster_size;
start_time=time(NULL);
previous_time=start_time;
current_search_space=td_list_last_entry(&list_search_space->list, alloc_data_t, list);
Expand Down
2 changes: 2 additions & 0 deletions src/phcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ int menu_photorec_cli(list_part_t *list_part, struct ph_param *params, struct ph
{
params->cmd_run+=7;
interface_options_photorec_cli(options, &params->cmd_run);
/* So we get it downstream in file_finish_*. */
params->report_only=options->report_only;
}
else if(strncmp(params->cmd_run,"fileopt",7)==0)
{
Expand Down
4 changes: 3 additions & 1 deletion src/phmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ int main( int argc, char **argv )
.expert=0,
.lowmem=0,
.verbose=0,
.list_file_format=list_file_enable
.list_file_format=list_file_enable,
.report_only=0
};
struct ph_param params;
params.recup_dir=NULL;
params.cmd_device=NULL;
params.cmd_run=NULL;
params.carve_free_space_only=0;
params.report_only=0;
/* random (weak is ok) is need fot GPT */
srand(time(NULL));
#ifdef HAVE_SIGACTION
Expand Down
2 changes: 2 additions & 0 deletions src/photorec.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ static void file_finish_aux(file_recovery_t *file_recovery, struct ph_param *par
set_date(file_recovery->filename, file_recovery->time, file_recovery->time);
if(file_recovery->file_rename!=NULL)
file_recovery->file_rename(file_recovery);
if(params->report_only)
unlink(file_recovery->filename);
if((++params->file_nbr)%MAX_FILES_PER_DIR==0)
{
params->dir_num=photorec_mkdir(params->recup_dir, params->dir_num+1);
Expand Down
2 changes: 2 additions & 0 deletions src/photorec.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct ph_options
{
int paranoid;
int keep_corrupted_file;
int report_only;
unsigned int mode_ext2;
unsigned int expert;
unsigned int lowmem;
Expand All @@ -51,6 +52,7 @@ struct ph_param
char *cmd_run;
disk_t *disk;
partition_t *partition;
int report_only;
unsigned int carve_free_space_only;
unsigned int blocksize;
unsigned int pass;
Expand Down
10 changes: 8 additions & 2 deletions src/phrecn.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,15 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
#ifdef HAVE_NCURSES
void interface_options_photorec_ncurses(struct ph_options *options)
{
unsigned int menu = 5;
unsigned int menu = 6;
struct MenuItem menuOptions[]=
{
{ 'P', NULL, "Check JPG files" },
{ 'K',NULL,"Keep corrupted files"},
{ 'S',NULL,"Try to skip indirect block"},
{ 'E',NULL,"Provide additional controls"},
{ 'L',NULL,"Low memory"},
{ 'R',NULL,"Report only - don't recover files"},
{ 'Q',"Quit","Return to main menu"},
{ 0, NULL, NULL }
};
Expand All @@ -525,8 +526,9 @@ void interface_options_photorec_ncurses(struct ph_options *options)
menuOptions[2].name=options->mode_ext2?"ext2/ext3 mode: Yes":"ext2/ext3 mode : No";
menuOptions[3].name=options->expert?"Expert mode : Yes":"Expert mode : No";
menuOptions[4].name=options->lowmem?"Low memory: Yes":"Low memory: No";
menuOptions[5].name=options->report_only?"Report only - don't recover files: Yes":"Report only - don't recover files: No";
aff_copy(stdscr);
car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "PKELQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "PKELRQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
switch(car)
{
case 'p':
Expand All @@ -552,6 +554,10 @@ void interface_options_photorec_ncurses(struct ph_options *options)
case 'L':
options->lowmem=!options->lowmem;
break;
case 'r':
case 'R':
options->report_only=!options->report_only;
break;
case key_ESC:
case 'q':
case 'Q':
Expand Down
11 changes: 9 additions & 2 deletions src/poptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ void interface_options_photorec_cli(struct ph_options *options, char **current_c
(*current_cmd)+=6;
options->lowmem=1;
}
/* report_only */
else if(strncmp(*current_cmd,"report_only",11)==0)
{
(*current_cmd)+=11;
options->report_only=1;
}
else
{
interface_options_photorec_log(options);
Expand All @@ -100,9 +106,10 @@ void interface_options_photorec_log(const struct ph_options *options)
/* write new options to log file */
log_info("New options :\n Paranoid : %s\n", options->paranoid?"Yes":"No");
log_info(" Brute force : %s\n", ((options->paranoid)>1?"Yes":"No"));
log_info(" Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n",
log_info(" Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n Report only : %s\n",
options->keep_corrupted_file?"Yes":"No",
options->mode_ext2?"Yes":"No",
options->expert?"Yes":"No",
options->lowmem?"Yes":"No");
options->lowmem?"Yes":"No",
options->report_only?"Yes":"No");
}
2 changes: 2 additions & 0 deletions src/ppartseln.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
case 'O':
{
interface_options_photorec_ncurses(options);
/* So we get it downstream in file_finish_*. */
params->report_only=options->report_only;
menu=1;
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/qphotorec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ QPhotorec::QPhotorec(QWidget *my_parent) : QWidget(my_parent)
options->mode_ext2=0;
options->expert=0;
options->lowmem=0;
options->report_only=0;
options->verbose=0;
options->list_file_format=list_file_enable;
reset_list_file_enable(options->list_file_format);
Expand Down
2 changes: 2 additions & 0 deletions src/sessionp.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ int session_save(alloc_data_t *list_free_space, struct ph_param *params, const
fprintf(f_session, "expert,");
if(options->lowmem>0)
fprintf(f_session, "lowmem,");
if(options->report_only>0)
fprintf(f_session, "report_only,");
/* Save options - End */
if(params->carve_free_space_only>0)
fprintf(f_session,"freespace,");
Expand Down