|
a/src/utils/smallut.cpp |
|
b/src/utils/smallut.cpp |
|
... |
|
... |
12 |
* You should have received a copy of the GNU General Public License
|
12 |
* You should have received a copy of the GNU General Public License
|
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
|
|
17 |
|
17 |
#ifndef TEST_SMALLUT
|
18 |
#ifndef TEST_SMALLUT
|
|
|
19 |
#ifdef HAVE_CONFIG_H
|
|
|
20 |
#include "autoconfig.h"
|
|
|
21 |
#endif
|
18 |
#include <stdio.h>
|
22 |
#include <stdio.h>
|
19 |
#include <stdlib.h>
|
23 |
#include <stdlib.h>
|
20 |
#include <time.h>
|
24 |
#include <time.h>
|
21 |
#include <ctype.h>
|
25 |
#include <ctype.h>
|
22 |
#include <unistd.h>
|
26 |
#include <unistd.h>
|
|
... |
|
... |
554 |
}
|
558 |
}
|
555 |
return true;
|
559 |
return true;
|
556 |
}
|
560 |
}
|
557 |
|
561 |
|
558 |
// Convert byte count into unit (KB/MB...) appropriate for display
|
562 |
// Convert byte count into unit (KB/MB...) appropriate for display
|
559 |
string displayableBytes(long size)
|
563 |
string displayableBytes(off_t size)
|
560 |
{
|
564 |
{
|
561 |
char sizebuf[30];
|
565 |
char sizebuf[30];
|
562 |
const char * unit = " B ";
|
566 |
const char * unit = " B ";
|
563 |
|
567 |
|
564 |
if (size > 1024 && size < 1024*1024) {
|
568 |
if (size > 1024 && size < 1024*1024) {
|
|
... |
|
... |
566 |
size /= 1024;
|
570 |
size /= 1024;
|
567 |
} else if (size >= 1024*1204) {
|
571 |
} else if (size >= 1024*1204) {
|
568 |
unit = " MB ";
|
572 |
unit = " MB ";
|
569 |
size /= (1024*1024);
|
573 |
size /= (1024*1024);
|
570 |
}
|
574 |
}
|
571 |
sprintf(sizebuf, "%ld%s", size, unit);
|
575 |
sprintf(sizebuf, OFFTPC "%s", size, unit);
|
572 |
return string(sizebuf);
|
576 |
return string(sizebuf);
|
573 |
}
|
577 |
}
|
574 |
|
578 |
|
575 |
string breakIntoLines(const string& in, unsigned int ll,
|
579 |
string breakIntoLines(const string& in, unsigned int ll,
|
576 |
unsigned int maxlines)
|
580 |
unsigned int maxlines)
|