void printHumanReadSize(const char *output, unsigned long long int splitgroesse)
{
unsigned long long humanread;
- char einheit = 'B';
+ char einheit[6] = {'B', 'K', 'M', 'G', 'T', 'P'};
char i = 0;
humanread = splitgroesse;
while (humanread >= 1024) {
- i++;
humanread /= 1024;
-
- switch (i) {
- case 1:
- einheit = 'K';
- break;
- case 2:
- einheit = 'M';
- break;
- case 3:
- einheit = 'G';
- break;
- }
+ i++;
}
+ if (i > sizeof(einheit)/sizeof(einheit[0]))
+ i = 0;
+
printf("Restlicher Platz in Bytes(%s): %lld (%lld %c)\n", output,
- splitgroesse, humanread, einheit);
+ splitgroesse, humanread, *(einheit + i));
}
int cmpfunc(const void *filea, const void *fileb)