[*_restore] Add progress bar to cache_restore and era_restore.

A lot of refactoring common code between the restore tools.
This commit is contained in:
Joe Thornber
2014-08-26 13:05:21 +01:00
parent e31ffe0874
commit 828f654800
18 changed files with 199 additions and 92 deletions

View File

@@ -236,13 +236,16 @@ caching::create_xml_emitter(ostream &out)
}
void
caching::parse_xml(istream &in, emitter::ptr e)
caching::parse_xml(istream &in, emitter::ptr e,
size_t input_length, base::progress_monitor &monitor)
{
xml_parser p;
XML_SetUserData(p.get_parser(), e.get());
XML_SetElementHandler(p.get_parser(), start_tag, end_tag);
size_t total = 0;
while (!in.eof()) {
char buffer[4096];
in.read(buffer, sizeof(buffer));
@@ -258,6 +261,9 @@ caching::parse_xml(istream &in, emitter::ptr e)
<< endl;
throw runtime_error(out.str());
}
total += len;
monitor.update_percent(total * 100 / input_length);
}
}