From 4ee16ef247a59b58061977296565edb3f2a55b43 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 12 Jul 2008 18:54:20 +0000 Subject: [PATCH] use new file_progress api in client_test --- examples/client_test.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 3e568c605..32a5d7c45 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1451,16 +1451,18 @@ int main(int ac, char* av[]) && s.state != torrent_status::seeding && h.has_metadata()) { - std::vector file_progress; + std::vector file_progress; h.file_progress(file_progress); torrent_info const& info = h.get_torrent_info(); for (int i = 0; i < info.num_files(); ++i) { - if (file_progress[i] == 1.f) - out << progress_bar(file_progress[i], 60, "32"); + float progress = info.file_at(i).size > 0 + ?float(file_progress[i]) / info.file_at(i).size:1; + if (file_progress[i] == info.file_at(i).size) + out << progress_bar(1.f, 100, "32"); else - out << progress_bar(file_progress[i], 60, "33"); - out << " " << to_string(file_progress[i] * 100.f, 5) << "% " + out << progress_bar(progress, 100, "33"); + out << " " << to_string(progress * 100.f, 5) << "% " << info.file_at(i).path.leaf() << "\n"; }