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
12 changes: 9 additions & 3 deletions src/phnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ pstatus_t photorec_progressbar(WINDOW *window, const unsigned int pass, const st
}
else
{
wprintw(window,"Pass %u - Reading sector %10llu/%llu, ",
wprintw(window,"Pass %u - Reading sector %10llu/%llu (%llu.%llu%%), ",
pass,
(unsigned long long)((offset-partition->part_offset)/sector_size),
(unsigned long long)(partition->part_size/sector_size));
(unsigned long long)(partition->part_size/sector_size),
(unsigned long long)((offset-partition->part_offset)*100/partition->part_size),
(unsigned long long)((offset-partition->part_offset)*1000/partition->part_size%10));
}
if(params->status==STATUS_FIND_OFFSET)
wprintw(window,"%u/10 headers found\n", params->file_nbr);
Expand Down Expand Up @@ -130,6 +132,10 @@ pstatus_t photorec_progressbar(WINDOW *window, const unsigned int pass, const st
json_log_progress(params, pass, offset);

wrefresh(window);
return(check_enter_key_or_s(window)==0?PSTATUS_OK:PSTATUS_STOP);
{
const int key=check_enter_key_or_s(window);
if(key==3) return PSTATUS_SKIP;
return (key==0?PSTATUS_OK:PSTATUS_STOP);
}
}
#endif
2 changes: 1 addition & 1 deletion src/photorec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
enum photorec_status { STATUS_FIND_OFFSET, STATUS_UNFORMAT, STATUS_EXT2_ON, STATUS_EXT2_ON_BF, STATUS_EXT2_OFF, STATUS_EXT2_OFF_BF, STATUS_EXT2_ON_SAVE_EVERYTHING, STATUS_EXT2_OFF_SAVE_EVERYTHING, STATUS_QUIT };
typedef enum photorec_status photorec_status_t;

typedef enum { PSTATUS_OK=0, PSTATUS_STOP=1, PSTATUS_EACCES=2, PSTATUS_ENOSPC=3} pstatus_t;
typedef enum { PSTATUS_OK=0, PSTATUS_STOP=1, PSTATUS_EACCES=2, PSTATUS_ENOSPC=3, PSTATUS_SKIP=4} pstatus_t;
typedef enum { PFSTATUS_BAD=0, PFSTATUS_OK=1, PFSTATUS_OK_TRUNCATED=2} pfstatus_t;

struct ph_options
Expand Down
43 changes: 43 additions & 0 deletions src/psearchn.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,49 @@ pstatus_t photorec_aux(struct ph_param *params, const struct ph_options *options
#endif
json_log_progress(params, params->pass, offset);
params->offset=offset;
if(ind_stop==PSTATUS_SKIP)
{
const uint64_t skip_bytes=params->partition->part_size/20;
const uint64_t target=offset+skip_bytes;
const uint64_t sector_size=params->disk->sector_size;
#ifdef HAVE_NCURSES
if(ask_confirmation("Skip ahead 5%% from sector %llu to ~%llu? (Y/N)",
(unsigned long long)((offset-params->partition->part_offset)/sector_size),
(unsigned long long)((target-params->partition->part_offset)/sector_size))==0)
{
ind_stop=PSTATUS_OK;
}
else
#endif
{
alloc_data_t *sp;
const uint64_t from_sector=(offset-params->partition->part_offset)/sector_size;
current_search_space=list_search_space;
td_list_for_each_entry(sp, &list_search_space->list, list)
{
if(sp->end>=target)
{
const uint64_t aligned=(target/blocksize)*blocksize;
current_search_space=sp;
offset=(aligned>=sp->start)?aligned:sp->start;
break;
}
}
log_info("User skipped from sector %llu to sector %llu\n",
(unsigned long long)from_sector,
(unsigned long long)((offset-params->partition->part_offset)/sector_size));
file_recovery_aborted(&file_recovery, params, list_search_space);
reset_file_recovery(&file_recovery);
file_recovery.blocksize=blocksize;
back=0;
memset(buffer_start,0,blocksize);
buffer_olddata=buffer_start;
buffer=buffer_olddata+blocksize;
params->disk->pread(params->disk, buffer, READ_SIZE, offset);
params->offset=offset;
ind_stop=PSTATUS_OK;
}
}
if(need_to_stop!=0 || ind_stop!=PSTATUS_OK)
{
#ifndef DISABLED_FOR_FRAMAC
Expand Down