#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
constexpr int chunk = 1024 * 1024;
constexpr int progress_interval = 1000;
// static const char * filename = "/tmp/file4GB-.bin";
static const char * filename = "/tmp/file4GB.bin";
StdLogSetup(LOG_COUT | LOG_TIMESTAMP);
RLOG("File '" << filename << "' sha1 calculation started");
Sha1Stream sha1;
FileIn file(filename);
auto size = file.GetSize();
auto last_progress = msecs();
while (!file.IsError() && !file.IsEof()) {
auto buff = file.Get(chunk);
if (buff.GetCount() <= 0) break;
sha1.Put(buff);
if (msecs(last_progress) > progress_interval) {
last_progress = msecs();
if (size > 0) RLOG("Progress: " << 100 * file.GetPos() / size << "%");
}
}
if (!file.IsError()) RLOG("SHA1: " << sha1.FinishString());
else RLOG("File '" << filename << "' sha1 calculation interrupted by error: '" << file.GetErrorText() << "'");
}
openssl rand 1073741824 > /tmp/file4GB-.bin
openssl rand 1073741824 >> /tmp/file4GB-.bin
openssl rand 1073741824 >> /tmp/file4GB-.bin
openssl rand 1073741823 >> /tmp/file4GB-.bin
openssl rand 1073741824 > /tmp/file4GB.bin
openssl rand 1073741824 >> /tmp/file4GB.bin
openssl rand 1073741824 >> /tmp/file4GB.bin
openssl rand 1073741824 >> /tmp/file4GB.bin