Enhancement - statistics

- Added total data file size to statistics report.
- Implemented util.cpp/formatBytes.
This commit is contained in:
Paul Beckingham
2009-06-18 19:47:57 -04:00
parent ec17eaaa43
commit aeaf443f67
3 changed files with 35 additions and 0 deletions

View File

@@ -147,6 +147,20 @@ std::string formatSecondsCompact (time_t delta)
return std::string (formatted);
}
////////////////////////////////////////////////////////////////////////////////
// Convert a quantity in seconds to a more readable format.
std::string formatBytes (size_t bytes)
{
char formatted[24];
if (bytes > 1000000000) sprintf (formatted, "%.1f GiB", (bytes / 1000000000.0));
else if (bytes > 1000000) sprintf (formatted, "%.1f MiB", (bytes / 1000000.0));
else if (bytes > 1000) sprintf (formatted, "%.1f KiB", (bytes / 1000.0));
else sprintf (formatted, "%d B", (int)bytes );
return commify (formatted);
}
////////////////////////////////////////////////////////////////////////////////
int autoComplete (
const std::string& partial,