Hi Jules,
would you consider adding the following changes to the ZipFile::Builder class to allow monitoring with a ProgressBar. It’s not perfect as it only shows the progress of processed files but not file size, but from a quick glance including the latter looks quite more complicated.
class Builder
{
// [...]
bool writeToStream (OutputStream& target, double* progress = 0) const;
// [...]
};
bool ZipFile::Builder::writeToStream (OutputStream& target, double* progress) const
{
const int64 fileStart = target.getPosition();
if (progress != 0)
*progress = 0;
int i;
for (i = 0; i < items.size(); ++i)
{
if (! items.getUnchecked (i)->writeData (target, fileStart))
return false;
if (progress != 0)
*progress = i / (double) items.size();
}
const int64 directoryStart = target.getPosition();
if (progress != 0)
*progress = (items.size()-0.5) / (double) items.size();
for (i = 0; i < items.size(); ++i)
if (! items.getUnchecked (i)->writeDirectoryEntry (target))
return false;
const int64 directoryEnd = target.getPosition();
target.writeInt (0x06054b50);
target.writeShort (0);
target.writeShort (0);
target.writeShort ((short) items.size());
target.writeShort ((short) items.size());
target.writeInt ((int) (directoryEnd - directoryStart));
target.writeInt ((int) (directoryStart - fileStart));
target.writeShort (0);
if (progress != 0)
*progress = 1;
return true;
}
Alternatively to the given code, progress could be a public member, but then writeToStream couldn’t be const any more.
Chris