GUI restable: fix sorting by file and doc size

This commit is contained in:
"Jean-Francois Dockes ext:(%22)
2011-07-20 10:44:04 +02:00
parent 6b04fe7f2c
commit 48e86c99b5
5 changed files with 48 additions and 13 deletions
+10 -4
View File
@@ -562,16 +562,22 @@ bool pcSubst(const string& in, string& out, map<string, string>& subs)
// Convert byte count into unit (KB/MB...) appropriate for display
string displayableBytes(off_t size)
{
char sizebuf[30];
const char * unit = " B ";
char sizebuf[50];
const char *unit;
if (size > 1024 && size < 1024*1024) {
if (size < 1024) {
unit = " B ";
} else if (size < 1024*1024) {
unit = " KB ";
size /= 1024;
} else if (size >= 1024*1204) {
} else if (size < 1024*1024*1024) {
unit = " MB ";
size /= (1024*1024);
} else {
unit = " GB ";
size /= (1024*1024*1024);
}
sprintf(sizebuf, OFFTPC "%s", size, unit);
return string(sizebuf);
}
+6
View File
@@ -178,6 +178,12 @@ struct TempBuf {
char *m_buf;
};
inline void leftzeropad(string& s, unsigned len)
{
if (s.length() && s.length() < len)
s = s.insert(0, len - s.length(), '0');
}
#ifndef deleteZ
#define deleteZ(X) {delete X;X = 0;}
#endif