if (!skipWriting) {
log(action + archiveType + ": " + zipFile.getAbsolutePath());
}
ZipOutputStream zOut = null;
try {
if (!skipWriting) {
zOut = new ZipOutputStream(zipFile);
zOut.setEncoding(encoding);
zOut.setUseLanguageEncodingFlag(useLanguageEncodingFlag);
zOut.setCreateUnicodeExtraFields(createUnicodeExtraFields.
getPolicy());
zOut.setFallbackToUTF8(fallBackToUTF8);
zOut.setMethod(doCompress
? ZipOutputStream.DEFLATED : ZipOutputStream.STORED);
zOut.setLevel(level);
}
initZipOutputStream(zOut);
// Add the explicit resource collections to the archive.
for (int i = 0; i < fss.length; i++) {
if (addThem[i].length != 0) {
addResources(fss[i], addThem[i], zOut);
}
}
if (doUpdate) {
addingNewFiles = false;
ZipFileSet oldFiles = new ZipFileSet();
oldFiles.setProject(getProject());
oldFiles.setSrc(renamedFile);
oldFiles.setDefaultexcludes(false);
final int addSize = addedFiles.size();
for (int i = 0; i < addSize; i++) {
PatternSet.NameEntry ne = oldFiles.createExclude();
ne.setName((String) addedFiles.elementAt(i));
}
DirectoryScanner ds =
oldFiles.getDirectoryScanner(getProject());
((ZipScanner) ds).setEncoding(encoding);
String[] f = ds.getIncludedFiles();
Resource[] r = new Resource[f.length];
for (int i = 0; i < f.length; i++) {
r[i] = ds.getResource(f[i]);
}
if (!doFilesonly) {
String[] d = ds.getIncludedDirectories();
Resource[] dr = new Resource[d.length];
for (int i = 0; i < d.length; i++) {
dr[i] = ds.getResource(d[i]);
}
Resource[] tmp = r;
r = new Resource[tmp.length + dr.length];
System.arraycopy(dr, 0, r, 0, dr.length);
System.arraycopy(tmp, 0, r, dr.length, tmp.length);
}
addResources(oldFiles, r, zOut);
}
if (zOut != null) {
zOut.setComment(comment);
}
finalizeZipOutputStream(zOut);
// If we've been successful on an update, delete the
// temporary file