forked from simonsj/fdupes-jody
-
Notifications
You must be signed in to change notification settings - Fork 0
/
act_summarize.c
41 lines (36 loc) · 1.08 KB
/
act_summarize.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Print summary of match statistics to stdout
* This file is part of jdupes; see jdupes.c for license information */
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "jdupes.h"
#include "act_summarize.h"
extern void summarizematches(const file_t * restrict files)
{
unsigned int numsets = 0;
off_t numbytes = 0;
int numfiles = 0;
while (files != NULL) {
file_t *tmpfile;
if (ISFLAG(files->flags, F_HAS_DUPES)) {
numsets++;
tmpfile = files->duplicates;
while (tmpfile != NULL) {
numfiles++;
numbytes += files->size;
tmpfile = tmpfile->duplicates;
}
}
files = files->next;
}
if (numsets == 0)
printf("No duplicates found.\n");
else
{
printf("%d duplicate files (in %d sets), occupying ", numfiles, numsets);
if (numbytes < 1000) printf("%" PRIdMAX " byte%c\n", (intmax_t)numbytes, (numbytes != 1) ? 's' : ' ');
else if (numbytes <= 1000000) printf("%" PRIdMAX " KB\n", (intmax_t)(numbytes / 1000));
else printf("%" PRIdMAX " MB\n", (intmax_t)(numbytes / 1000000));
}
return;
}