Skip to content
Open
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
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
else if(check_command(&params->cmd_run,"options",7)==0)
{
interface_options_photorec_cli(options, &params->cmd_run);
/* So we get it downstream in file_finish_*. */
params->report_only=options->report_only;
}
else if(check_command(&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 @@ -159,13 +159,15 @@ int main( int argc, char **argv )
.expert=0,
.lowmem=0,
.verbose=0,
.list_file_format=array_file_enable
.list_file_format=array_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
22 changes: 15 additions & 7 deletions src/photorec.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,26 @@ static void file_finish_aux(file_recovery_t *file_recovery, struct ph_param *par
return;
}
#if defined(HAVE_FTRUNCATE)
fflush(file_recovery->handle);
if(ftruncate(fileno(file_recovery->handle), file_recovery->file_size)<0)
if(!params->report_only)
{
log_critical("ftruncate failed.\n");
fflush(file_recovery->handle);
if(ftruncate(fileno(file_recovery->handle), file_recovery->file_size)<0)
{
log_critical("ftruncate failed.\n");
}
}
#endif
fclose(file_recovery->handle);
file_recovery->handle=NULL;
if(file_recovery->time!=0 && file_recovery->time!=(time_t)-1)
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);
else
{
if(file_recovery->time!=0 && file_recovery->time!=(time_t)-1)
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->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 @@ -487,14 +487,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 @@ -518,8 +519,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 @@ -545,6 +547,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 @@ -78,6 +78,12 @@ void interface_options_photorec_cli(struct ph_options *options, char **current_c
{
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 @@ -91,9 +97,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=array_file_enable;
reset_array_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 @@ -261,6 +261,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