2013-07-03 02:52:38 +00:00
|
|
|
/* Copyright (c) 2008-2013, Avian Contributors
|
2011-03-26 01:14:21 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
|
|
for any purpose with or without fee is hereby granted, provided
|
|
|
|
that the above copyright notice and this permission notice appear
|
|
|
|
in all copies.
|
|
|
|
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
package java.util.jar;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.zip.ZipFile;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
|
|
|
public class JarFile extends ZipFile {
|
|
|
|
public JarFile(String name) throws IOException {
|
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public JarFile(File file) throws IOException {
|
|
|
|
super(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Enumeration<JarEntry> entries() {
|
|
|
|
return (Enumeration<JarEntry>) makeEnumeration(JarEntryFactory.Instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
public JarEntry getJarEntry(String name) {
|
|
|
|
return (JarEntry) getEntry(JarEntryFactory.Instance, name);
|
|
|
|
}
|
|
|
|
|
2011-05-16 16:30:56 +00:00
|
|
|
private static class MyJarEntry extends JarEntry implements MyEntry {
|
2011-03-26 01:14:21 +00:00
|
|
|
public final Window window;
|
|
|
|
public final int pointer;
|
|
|
|
|
|
|
|
public MyJarEntry(Window window, int pointer) {
|
|
|
|
this.window = window;
|
|
|
|
this.pointer = pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
try {
|
|
|
|
return entryName(window, pointer);
|
|
|
|
} catch (IOException e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-06 21:56:02 +00:00
|
|
|
public long getCompressedSize() {
|
2011-03-26 01:14:21 +00:00
|
|
|
try {
|
|
|
|
return compressedSize(window, pointer);
|
|
|
|
} catch (IOException e) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-06 21:56:02 +00:00
|
|
|
public long getSize() {
|
2011-03-26 01:14:21 +00:00
|
|
|
try {
|
|
|
|
return uncompressedSize(window, pointer);
|
|
|
|
} catch (IOException e) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2011-05-16 16:30:56 +00:00
|
|
|
|
|
|
|
public int pointer() {
|
|
|
|
return pointer;
|
|
|
|
}
|
2011-03-26 01:14:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static class JarEntryFactory implements EntryFactory {
|
|
|
|
public static final JarEntryFactory Instance = new JarEntryFactory();
|
|
|
|
|
|
|
|
public ZipEntry makeEntry(Window window, int pointer) {
|
|
|
|
return new MyJarEntry(window, pointer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|