summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/TorrentConsoleDownloadEngine.cc2
-rw-r--r--src/Util.cc6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/TorrentConsoleDownloadEngine.cc b/src/TorrentConsoleDownloadEngine.cc
index 401c7939..da582e0c 100644
--- a/src/TorrentConsoleDownloadEngine.cc
+++ b/src/TorrentConsoleDownloadEngine.cc
@@ -58,7 +58,7 @@ void TorrentConsoleDownloadEngine::sendStatistics() {
}
printf(" U:%.2f(%s) %d peers",
uploadSpeed/1024.0,
- Util::llitos(uploadLength, true).c_str(),
+ Util::abbrevSize(uploadLength).c_str(),
btRuntime->getConnections());
fflush(stdout);
}
diff --git a/src/Util.cc b/src/Util.cc
index 5a6342ce..15709862 100644
--- a/src/Util.cc
+++ b/src/Util.cc
@@ -697,14 +697,16 @@ string Util::abbrevSize(int64_t size)
if(size < 1024) {
return Util::llitos(size, true);
}
- size >>= 10;
char units[] = { 'K', 'M' };
int32_t numUnit = sizeof(units)/sizeof(char);
int32_t i = 0;
+ int32_t r = size%1024;
+ size >>= 10;
for(; i < numUnit-1 && size >= 1024; ++i) {
+ r = size%1024;
size >>= 10;
}
- return Util::llitos(size, true)+units[i];
+ return Util::llitos(size, true)+"."+Util::itos(r*10/1024)+units[i];
}
time_t Util::httpGMT(const string& httpStdTime)