PhotoRec: if less than 10 file famillies are enabled, display the results even if zero file have been found yet.

This commit is contained in:
Christophe Grenier 2012-01-27 08:43:56 +01:00
parent d256adb147
commit 71d5bddcff

View file

@ -49,7 +49,6 @@ void photorec_info(WINDOW *window, const file_stat_t *file_stats)
{ {
unsigned int i; unsigned int i;
unsigned int nbr; unsigned int nbr;
unsigned int others=0;
file_stat_t *new_file_stats; file_stat_t *new_file_stats;
for(i=0;file_stats[i].file_hint!=NULL;i++); for(i=0;file_stats[i].file_hint!=NULL;i++);
nbr=i; nbr=i;
@ -58,25 +57,41 @@ void photorec_info(WINDOW *window, const file_stat_t *file_stats)
new_file_stats=(file_stat_t*)MALLOC(nbr*sizeof(file_stat_t)); new_file_stats=(file_stat_t*)MALLOC(nbr*sizeof(file_stat_t));
memcpy(new_file_stats, file_stats, nbr*sizeof(file_stat_t)); memcpy(new_file_stats, file_stats, nbr*sizeof(file_stat_t));
qsort(new_file_stats, nbr, sizeof(file_stat_t), sorfile_stat_ts); qsort(new_file_stats, nbr, sizeof(file_stat_t), sorfile_stat_ts);
for(i=0;i<nbr && new_file_stats[i].recovered>0;i++) if(nbr<=10)
{ {
if(i<10) for(i=0; i<nbr; i++)
{ {
wmove(window,11+i,0); wmove(window,11+i,0);
wclrtoeol(window); wclrtoeol(window);
wprintw(window, "%s: %u recovered\n", wprintw(window, "%s: %u recovered\n",
(new_file_stats[i].file_hint->extension!=NULL? (new_file_stats[i].file_hint->extension!=NULL?
new_file_stats[i].file_hint->extension:""), new_file_stats[i].file_hint->extension:""),
new_file_stats[i].recovered); new_file_stats[i].recovered);
} }
else
others+=new_file_stats[i].recovered;
} }
if(others>0) else
{ {
wmove(window,11+10,0); unsigned int others=0;
wclrtoeol(window); for(i=0;i<nbr && new_file_stats[i].recovered>0;i++)
wprintw(window, "others: %u recovered\n", others); {
if(i<10)
{
wmove(window,11+i,0);
wclrtoeol(window);
wprintw(window, "%s: %u recovered\n",
(new_file_stats[i].file_hint->extension!=NULL?
new_file_stats[i].file_hint->extension:""),
new_file_stats[i].recovered);
}
else
others+=new_file_stats[i].recovered;
}
if(others>0)
{
wmove(window,11+10,0);
wclrtoeol(window);
wprintw(window, "others: %u recovered\n", others);
}
} }
free(new_file_stats); free(new_file_stats);
} }