blob: a395ca3f11e2c0a609e417a16ff8f0718084febb [file] [log] [blame]
Patrick Venturecf9b2192019-06-27 12:09:52 -07001/*
2 * Copyright 2019 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "progress.hpp"
18
19#include <cstdio>
20
21namespace host_tool
22{
23
24void ProgressStdoutIndicator::updateProgress(std::int64_t bytes)
25{
26 /* Print progress update. */
27 currentBytes += bytes;
28 std::fprintf(stdout, "\rProgress: %.2f%%",
29 100.0 * currentBytes / totalBytes);
30 std::fflush(stdout);
31}
32
33void ProgressStdoutIndicator::start(std::int64_t bytes)
34{
35 totalBytes = bytes;
36 currentBytes = 0;
37}
38
39} // namespace host_tool