progress.beginTask("Creating Archive", files.size());
OutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(archive));
CheckedOutputStream cos = null;
if (calculateChecksum) {
outputStream = cos = new CheckedOutputStream(outputStream,
new Adler32());
}
ZipOutputStream zipStream = new ZipOutputStream(outputStream);
for (IPath path : files) {
IFile file = project.getFile(path);
try {
zipSingleFile(new WrappedIFile(file), path.toPortableString(),
zipStream, progress.newChild(1));
} catch (SarosCancellationException e) {
cleanup(archive);
throw e;
} catch (IllegalArgumentException e) {
cleanup(archive);
throw e;
} catch (IOException e) {
cleanup(archive);
throw e;
}
}
zipStream.close();
// Checksum
if (calculateChecksum && cos != null) {
FileZipper.log.debug("Checksum: " + cos.getChecksum().getValue());
}
stopWatch.stop();
log.debug(String.format("Created project archive %s at %s", stopWatch
.throughput(archive.length()), archive.getAbsolutePath()));