}
entries.put(vPath, vPath);
if (!skipWriting) {
ZipEntry ze = new ZipEntry(vPath);
ze.setTime(lastModified);
ze.setMethod(doCompress ? ZipEntry.DEFLATED : ZipEntry.STORED);
/*
* ZipOutputStream.putNextEntry expects the ZipEntry to
* know its size and the CRC sum before you start writing
* the data when using STORED mode - unless it is seekable.
*
* This forces us to process the data twice.
*/
if (!zOut.isSeekable() && !doCompress) {
long size = 0;
CRC32 cal = new CRC32();
if (!in.markSupported()) {
// Store data into a byte[]
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
do {
size += count;
cal.update(buffer, 0, count);
bos.write(buffer, 0, count);
count = in.read(buffer, 0, buffer.length);
} while (count != -1);
in = new ByteArrayInputStream(bos.toByteArray());
} else {
in.mark(Integer.MAX_VALUE);
byte[] buffer = new byte[BUFFER_SIZE];
int count = 0;
do {
size += count;
cal.update(buffer, 0, count);
count = in.read(buffer, 0, buffer.length);
} while (count != -1);
in.reset();
}
ze.setSize(size);
ze.setCrc(cal.getValue());
}
ze.setUnixMode(mode);
ZipExtraField[] extra = getCurrentExtraFields();
if (extra != null) {
ze.setExtraFields(extra);
}
zOut.putNextEntry(ze);
byte[] buffer = new byte[BUFFER_SIZE];