prefix += "/";
}
addParentDirs(null, prefix, zOut, "", dirMode);
}
ZipFile zf = null;
try {
boolean dealingWithFiles = false;
File base = null;
if (zfs == null || zfs.getSrc(getProject()) == null) {
dealingWithFiles = true;
base = fileset.getDir(getProject());
} else if (zfs instanceof ZipFileSet) {
zf = new ZipFile(zfs.getSrc(getProject()), encoding);
}
for (int i = 0; i < resources.length; i++) {
String name = null;
if (fullpath.length() > 0) {
name = fullpath;
} else {
name = resources[i].getName();
}
name = name.replace(File.separatorChar, '/');
if ("".equals(name)) {
continue;
}
if (resources[i].isDirectory()) {
if (doFilesonly) {
continue;
}
int thisDirMode = zfs != null && zfs.hasDirModeBeenSet()
? dirMode : getUnixMode(resources[i], zf, dirMode);
addDirectoryResource(resources[i], name, prefix,
base, zOut,
dirMode, thisDirMode);
} else { // !isDirectory
addParentDirs(base, name, zOut, prefix, dirMode);
if (dealingWithFiles) {
File f = FILE_UTILS.resolveFile(base,
resources[i].getName());
zipFile(f, zOut, prefix + name, fileMode);
} else {
int thisFileMode =
zfs != null && zfs.hasFileModeBeenSet()
? fileMode : getUnixMode(resources[i], zf,
fileMode);
addResource(resources[i], name, prefix,
zOut, thisFileMode, zf,
zfs == null
? null : zfs.getSrc(getProject()));
}
}
}
} finally {
if (zf != null) {
zf.close();
}
}
}