while ((entry = zis.getNextEntry()) != null) {
String entryName = zipinfo.oldStyle ? removeTopDir(entry.getName()) : entry.getName();
if (!entryName.isEmpty()) {
if (entry.isDirectory()) {
if (!new File(directory, entryName).mkdir()) {
throw new PlatformManagerException("Failed to create directory");
}
} else {
int count;
byte[] buff = new byte[BUFFER_SIZE];
BufferedOutputStream dest = null;
try {
OutputStream fos = new FileOutputStream(new File(directory, entryName));
dest = new BufferedOutputStream(fos, BUFFER_SIZE);
while ((count = zis.read(buff, 0, BUFFER_SIZE)) != -1) {
dest.write(buff, 0, count);
}
dest.flush();
} finally {
if (dest != null) {
dest.close();
}
}
}
}
}
} catch (Exception e) {
throw new PlatformManagerException("Failed to unzip module", e);
} finally {
if (deleteZip) {
if (!new File(zipinfo.filename).delete()) {
log.error("Failed to delete zip");
}