diff options
author | Christophe Grenier <grenier@cgsecurity.org> | 2011-06-02 20:53:27 +0200 |
---|---|---|
committer | Christophe Grenier <grenier@cgsecurity.org> | 2011-06-02 20:53:27 +0200 |
commit | e0d5e35d6b15ae0e5a55252d6d8af09472e3b0c1 (patch) | |
tree | 18af714b226e2533ab4f4d6348decd848c4032b4 | |
parent | 0371a41375680c584c332524032441d47710f6ab (diff) |
PhotoRec: workaroud in progress bar when time goes backward
-rw-r--r-- | src/phbf.c | 5 | ||||
-rw-r--r-- | src/phnc.c | 21 | ||||
-rw-r--r-- | src/phrecn.c | 5 |
3 files changed, 20 insertions, 11 deletions
@@ -688,7 +688,10 @@ static int photorec_bf_frag(disk_t *disk_car, partition_t *partition, const char int ind_stop=0; previous_time=current_time; #ifdef HAVE_NCURSES - ind_stop=photorec_progressbar(stdscr, testbf, status, file_recovery->location.start, disk_car, partition, *file_nbr, current_time-real_start_time, file_stats); + ind_stop=photorec_progressbar(stdscr, testbf, status, + file_recovery->location.start, disk_car, partition, *file_nbr, + (current_time > real_start_time ? current_time - real_start_time: 0), + file_stats); #endif if(ind_stop!=0) { @@ -104,16 +104,19 @@ int photorec_progressbar(WINDOW *window, const unsigned int pass, const photorec } wmove(window,10,0); wclrtoeol(window); - wprintw(window,"Elapsed time %uh%02um%02us", - (unsigned)(elapsed_time/60/60), - (unsigned)(elapsed_time/60%60), - (unsigned)(elapsed_time%60)); - if(offset-partition->part_offset!=0 && (status!=STATUS_EXT2_ON_BF && status!=STATUS_EXT2_OFF_BF)) + if(elapsed_time>0) { - wprintw(window," - Estimated time to completion %uh%02um%02u\n", - (unsigned)((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset)/3600), - (unsigned)(((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset)/60)%60), - (unsigned)((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset))%60); + wprintw(window,"Elapsed time %uh%02um%02us", + (unsigned)(elapsed_time/60/60), + (unsigned)(elapsed_time/60%60), + (unsigned)(elapsed_time%60)); + if(offset > partition->part_offset && status!=STATUS_EXT2_ON_BF && status!=STATUS_EXT2_OFF_BF) + { + wprintw(window," - Estimated time to completion %uh%02um%02u\n", + (unsigned)((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset)/3600), + (unsigned)(((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset)/60)%60), + (unsigned)((partition->part_offset+partition->part_size-1-offset)*elapsed_time/(offset-partition->part_offset))%60); + } } photorec_info(window, file_stats); wrefresh(window); diff --git a/src/phrecn.c b/src/phrecn.c index 85c10b4..3f2bca8 100644 --- a/src/phrecn.c +++ b/src/phrecn.c @@ -486,7 +486,10 @@ static int photorec_aux(disk_t *disk_car, partition_t *partition, const int verb if(current_time>previous_time) { previous_time=current_time; - ind_stop=photorec_progressbar(stdscr, pass, status, offset, disk_car, partition, *file_nbr, current_time-real_start_time, file_stats); + ind_stop=photorec_progressbar(stdscr, pass, status, offset, disk_car, + partition, *file_nbr, + (current_time > real_start_time ? current_time - real_start_time: 0), + file_stats); } } #endif |