// skip MacOSX specific metadata directory
// create directories
getAllSubdirs(targetDir, oEntr.getName(), true);
} else {
// create file
VFSContainer createIn = targetDir;
String name = oEntr.getName();
// check if entry has directories which did not show up as
// directories above
int dirSepIndex = name.lastIndexOf('/');
if (dirSepIndex == -1) {
// try it windows style, backslash is also valid format
dirSepIndex = name.lastIndexOf('\\');
}
if (dirSepIndex > 0) {
// create subdirs
createIn = getAllSubdirs(targetDir, name.substring(0, dirSepIndex), true);
if (createIn == null) {
if (log.isDebug()) log.debug("Error creating directory structure for zip entry: "
+ oEntr.getName());
return false;
}
name = name.substring(dirSepIndex + 1);
}
if(versioning) {
VFSLeaf newEntry = (VFSLeaf)createIn.resolve(name);
if(newEntry == null) {
newEntry = createIn.createChildLeaf(name);
OutputStream out = newEntry.getOutputStream(false);
if (!FileUtils.copy(oZip, out)) return false;
FileUtils.closeSafely(out);
} else if (newEntry instanceof Versionable) {
Versionable versionable = (Versionable)newEntry;
if(versionable.getVersions().isVersioned()) {
versionable.getVersions().addVersion(identity, "", oZip);
}
}
} else {
VFSLeaf newEntry = createIn.createChildLeaf(name);
if (newEntry != null) {
OutputStream out = newEntry.getOutputStream(false);
if (!FileUtils.copy(oZip, out)) return false;
FileUtils.closeSafely(out);
}