diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-06-10 12:01:32 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-06-10 12:01:32 +0000 |
| commit | 6f96fdc5874f893815dc208eb446410bbce9fddd (patch) | |
| tree | 9d094ede67d3d0dd22b243d5d6c6fada2c7e23b3 /src | |
| parent | db41dfac206348ae55e969446917ccbe41915bbb (diff) | |
Show 1/10 unit in size
Diffstat (limited to 'src')
| -rw-r--r-- | src/TorrentConsoleDownloadEngine.cc | 2 | ||||
| -rw-r--r-- | src/Util.cc | 6 |
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) |
