private void executeUnzip() throws Exception {
File file = null;
JarFile jar;
Enumeration content;
JarEntry entry;
String classFile = "";
String filename = "";
long archiveDate;
long hdDate;
int extracted = 0;
int processed = 0;
// individuelle Manifest Sektionen
ArrayList iSecName = new ArrayList();
ArrayList iSecOrigin = new ArrayList();
ArrayList iSecDate = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String jarDate;
int index;
// Verzeichnis der Archive einlesen
file = new File( this.source );
// alle zu durchsuchenden jar- und zip-Archive ermitteln
String path = null;
String[] list = null;
if ( file.isDirectory() ) {
path = this.source;
list = this.archiveFilter(file.list());
} else {
path = file.getPath().substring(0,file.getPath().length()-file.getName().length());
list = new String[1];
list[0] = file.getName();
}
if ( list.length == 0 ) {
this.logln("\n no jar/zip archives found");
return;
}
if ( this.oldOverwrites )
this.logln("\n directive: overwrite newer versions");
else
this.logln("\n directive: overwrite older versions");
try {
// alle Archive durchgehen
for (int i=0; i<list.length; i++) {
this.logln("\n unpack "+ list[i] +":");
jar = new JarFile(path + list[i]);
content = jar.entries();
file = new File(path + list[i]);
jarDate = ( file.lastModified() < 0 ) ? "unknown" : sdf.format(new Date(file.lastModified()));
// alle Klassen eines Archivs durchgehen
while ( content.hasMoreElements() ) {
entry = (JarEntry)content.nextElement();
classFile = entry.getName();
if ( !(classFile.charAt(classFile.length()-1)=='/' || classFile.toUpperCase().equals("META-INF/MANIFEST.MF")) ) {
index = classFile.lastIndexOf('/')+1; // behandelt R�ckgabewert -1 implizit mit
// Dateiname muss vom regul�ren Ausdruck erfasst werden
if ( this.fileFilterPattern.matcher(classFile.substring(index)).matches() ) {
// Paketstruktur aufl�sen?
if ( this.detach )
filename = classFile.substring(index);
else
filename = classFile;
file = new File( ((this.targetPath!=null) ? this.targetPath : "") + filename );
// Datei existiert schon auf Platte
if ( file.canRead() ) {
hdDate = file.lastModified();
archiveDate = entry.getTime();
if ( (!this.oldOverwrites && (archiveDate > hdDate)) || (this.oldOverwrites && (archiveDate < hdDate)) ) {
this.unpackJarEntry(jar, entry, this.targetPath);
// f�r Manifest individuelle Sektionen