summaryrefslogtreecommitdiffstats
path: root/src/phnc.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-05-16 17:40:08 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-05-16 17:40:08 +0200
commite2a7fe2ee9346e897ceea4fc3165eda27d3ec4c8 (patch)
treef3eb2943e5feb0cd1cba2da461dc4b1e26662a4f /src/phnc.c
parent6fea3c525d844313daf9e299d176f7fe994931e4 (diff)
Refactor code in photorec_info()
Diffstat (limited to 'src/phnc.c')
-rw-r--r--src/phnc.c51
1 files changed, 14 insertions, 37 deletions
diff --git a/src/phnc.c b/src/phnc.c
index 2f6334c..4622ad6 100644
--- a/src/phnc.c
+++ b/src/phnc.c
@@ -36,19 +36,15 @@
#include "common.h"
#include "intrf.h"
#include "intrfn.h"
-#include "dir.h"
-#include "fat_dir.h"
-#include "list.h"
-#include "lang.h"
#include "filegen.h"
#include "photorec.h"
-#include "log.h"
#include "phnc.h"
void photorec_info(WINDOW *window, const file_stat_t *file_stats)
{
unsigned int i;
unsigned int nbr;
+ unsigned int others=0;
file_stat_t *new_file_stats;
for(i=0;file_stats[i].file_hint!=NULL;i++);
nbr=i;
@@ -57,41 +53,22 @@ void photorec_info(WINDOW *window, const file_stat_t *file_stats)
new_file_stats=(file_stat_t*)MALLOC(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);
- if(nbr<=10)
+ for(i=0; i<10 && i<nbr && new_file_stats[i].recovered>0; i++)
{
- for(i=0; i<nbr; i++)
- {
- 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);
- }
+ 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
+ for(;i<nbr && new_file_stats[i].recovered>0;i++)
+ others+=new_file_stats[i].recovered;
+ if(others>0)
{
- unsigned int others=0;
- for(i=0;i<nbr && new_file_stats[i].recovered>0;i++)
- {
- 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);
- }
+ wmove(window,11+10,0);
+ wclrtoeol(window);
+ wprintw(window, "others: %u recovered\n", others);
}
free(new_file_stats);
}