Implement progress output

This commit is contained in:
Leonetienne
2022-06-01 03:28:31 +02:00
parent fb1e6a9e8c
commit e8d81af6f2
9 changed files with 112 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
#include "ModuleDecryption.h"
#include "DataIngestionLayer.h"
#include "DataOutputLayer.h"
#include "ProgressPrinter.h"
#include "KeyManager.h"
#include <GCrypt/GCipher.h>
@@ -21,6 +22,7 @@ void Decryption::Run() {
GCipher::DIRECTION::DECIPHER
);
std::size_t nBlocksDigested = 0;
while (!IO::DataOutputLayer::IsFinished()) {
// Read in new blocks, if not reached eof
if (!IO::DataIngestionLayer::ReachedEOF()) {
@@ -29,8 +31,17 @@ void Decryption::Run() {
// Process a block, if one is ready
if (IO::DataIngestionLayer::IsBlockReady()) {
// Print progress, if appropriate
ProgressPrinter::PrintIfAppropriate(
"Decrypting",
nBlocksDigested,
IO::DataIngestionLayer::NBlocksRead()
);
const Block cleartext = IO::DataIngestionLayer::GetNextBlock();
const Block ciphertext = cipher.Digest(cleartext);
nBlocksDigested++;
// Enqueue the block for output
IO::DataOutputLayer::Enqueue(ciphertext);