tools: add progress implementation
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I9da1674d6cbc688efc7bab0e033788d6ee4694f7
diff --git a/tools/p2a.cpp b/tools/p2a.cpp
index 66fc62e..0ac5eb3 100644
--- a/tools/p2a.cpp
+++ b/tools/p2a.cpp
@@ -111,6 +111,15 @@
return false;
}
+ std::int64_t fileSize = sys->getSize(input.c_str());
+ if (fileSize == 0)
+ {
+ std::fprintf(stderr, "Zero-length file, or other file access error\n");
+ return false;
+ }
+
+ progress->start(fileSize);
+
const std::uint32_t p2aLength = aspeedP2aOffset;
auto readBuffer = std::make_unique<std::uint8_t[]>(p2aLength);
@@ -152,6 +161,7 @@
/* This doesn't return anything on success. */
blob->writeBytes(session, offset, chunkBytes);
offset += bytesRead;
+ progress->updateProgress(bytesRead);
}
} while (bytesRead > 0);
}