|
a/src/utils/smallut.cpp |
|
b/src/utils/smallut.cpp |
|
... |
|
... |
27 |
#include <errno.h>
|
27 |
#include <errno.h>
|
28 |
#include <time.h>
|
28 |
#include <time.h>
|
29 |
#include <sys/types.h>
|
29 |
#include <sys/types.h>
|
30 |
#include <sys/stat.h>
|
30 |
#include <sys/stat.h>
|
31 |
#include <string.h>
|
31 |
#include <string.h>
|
|
|
32 |
#include <math.h>
|
32 |
|
33 |
|
33 |
#include <string>
|
34 |
#include <string>
|
34 |
#include <iostream>
|
35 |
#include <iostream>
|
35 |
#include <list>
|
36 |
#include <list>
|
36 |
#include <tr1/unordered_map>
|
37 |
#include <tr1/unordered_map>
|
|
... |
|
... |
600 |
// Convert byte count into unit (KB/MB...) appropriate for display
|
601 |
// Convert byte count into unit (KB/MB...) appropriate for display
|
601 |
string displayableBytes(off_t size)
|
602 |
string displayableBytes(off_t size)
|
602 |
{
|
603 |
{
|
603 |
char sizebuf[50];
|
604 |
char sizebuf[50];
|
604 |
const char *unit;
|
605 |
const char *unit;
|
605 |
|
606 |
|
|
|
607 |
double roundable = 0;
|
606 |
if (size < 1000) {
|
608 |
if (size < 1000) {
|
607 |
unit = " B ";
|
609 |
unit = " B ";
|
|
|
610 |
roundable = double(size);
|
608 |
} else if (size < 1E6) {
|
611 |
} else if (size < 1E6) {
|
609 |
unit = " KB ";
|
612 |
unit = " KB ";
|
610 |
size /= 1000;
|
613 |
roundable = double(size) / 1E3;
|
611 |
} else if (size < 1E9) {
|
614 |
} else if (size < 1E9) {
|
612 |
unit = " MB ";
|
615 |
unit = " MB ";
|
613 |
size /= (1E6);
|
616 |
roundable = double(size) / 1E6;
|
614 |
} else {
|
617 |
} else {
|
615 |
unit = " GB ";
|
618 |
unit = " GB ";
|
616 |
size /= (1E9);
|
619 |
roundable = double(size) / 1E9;
|
617 |
}
|
620 |
}
|
618 |
|
621 |
size = round(roundable);
|
619 |
sprintf(sizebuf, OFFTPC "%s", size, unit);
|
622 |
sprintf(sizebuf, OFFTPC "%s", size, unit);
|
620 |
return string(sizebuf);
|
623 |
return string(sizebuf);
|
621 |
}
|
624 |
}
|
622 |
|
625 |
|
623 |
string breakIntoLines(const string& in, unsigned int ll,
|
626 |
string breakIntoLines(const string& in, unsigned int ll,
|