mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-09 11:42:33 +00:00
* Cleaned up rak::priority_queue.
* Added download time left display, need to tweak it. * Removed libtorrent/src/download/download_setup.cc. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@607 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -71,6 +71,18 @@ print_hhmmss(char* buf, unsigned int length, time_t t) {
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
char*
|
||||
print_hhhhmmss(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::localtime(&t);
|
||||
|
||||
if (u == NULL)
|
||||
return "inv_time";
|
||||
|
||||
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
||||
|
||||
return buf + std::min(s, length);
|
||||
}
|
||||
|
||||
char*
|
||||
print_ddmmyyyy(char* buf, unsigned int length, time_t t) {
|
||||
std::tm *u = std::gmtime(&t);
|
||||
@@ -110,6 +122,9 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
|
||||
(double)d->get_download().down_rate()->rate() / (1 << 10),
|
||||
(double)d->get_download().up_rate()->total() / (1 << 20)));
|
||||
|
||||
buf += std::max(0, snprintf(buf, length, " Left: "));
|
||||
buf = print_download_time_left(buf, length, d);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -138,6 +153,21 @@ print_download_status(char* buf, unsigned int length, core::Download* d) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_time_left(char* buf, unsigned int length, core::Download* d) {
|
||||
uint32_t rate;
|
||||
|
||||
if (!d->get_download().is_active() ||
|
||||
(rate = d->get_download().down_rate()->rate()) < 512) {
|
||||
buf += std::max(0, snprintf(buf, length, "--:--:--"));
|
||||
return buf;
|
||||
}
|
||||
|
||||
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
|
||||
|
||||
return print_hhhhmmss(buf, length, remaining);
|
||||
}
|
||||
|
||||
// char*
|
||||
// print_entry_tags(char* buf, unsigned int length) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user