tools: add progress implementation
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I9da1674d6cbc688efc7bab0e033788d6ee4694f7
diff --git a/tools/lpc.cpp b/tools/lpc.cpp
index 7dbfaf3..3616085 100644
--- a/tools/lpc.cpp
+++ b/tools/lpc.cpp
@@ -103,6 +103,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);
+
/* For Nuvoton the maximum is 4K */
auto readBuffer = std::make_unique<std::uint8_t[]>(host_lpc_buf.length);
if (nullptr == readBuffer)
@@ -140,6 +149,7 @@
/* This doesn't return anything on success. */
blob->writeBytes(session, offset, chunkBytes);
offset += bytesRead;
+ progress->updateProgress(bytesRead);
}
} while (bytesRead > 0);
}