GUI restable: fix sorting by file and doc size
This commit is contained in:
+10
-4
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user