home *** CD-ROM | disk | FTP | other *** search
- package java.util.zip;
-
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.security.AccessController;
- import java.util.Enumeration;
- import java.util.Vector;
- import sun.security.action.LoadLibraryAction;
-
- public class ZipFile implements ZipConstants {
- private long jzfile;
- private String name;
- private int total;
- private static final int STORED = 0;
- private static final int DEFLATED = 8;
- public static final int OPEN_READ = 1;
- public static final int OPEN_DELETE = 4;
- private Vector inflaters;
-
- private static native void initIDs();
-
- public ZipFile(String var1) throws IOException {
- this(new File(var1), 1);
- }
-
- public ZipFile(File var1, int var2) throws IOException {
- this.inflaters = new Vector();
- if ((var2 & 1) != 0 && (var2 & -6) == 0) {
- String var3 = var1.getPath();
- SecurityManager var4 = System.getSecurityManager();
- if (var4 != null) {
- var4.checkRead(var3);
- }
-
- this.jzfile = open(var3, var2);
- this.name = var3;
- this.total = getTotal(this.jzfile);
- } else {
- throw new IllegalArgumentException("Illegal mode: 0x" + Integer.toHexString(var2));
- }
- }
-
- private static native long open(String var0, int var1);
-
- private static native int getTotal(long var0);
-
- public ZipFile(File var1) throws ZipException, IOException {
- this(var1, 1);
- }
-
- public ZipEntry getEntry(String var1) {
- if (var1 == null) {
- throw new NullPointerException("name");
- } else if (this.jzfile == 0L) {
- throw new IllegalStateException("zip file closed");
- } else {
- long var2 = getEntry(this.jzfile, var1);
- if (var2 == 0L && !var1.endsWith("/")) {
- var2 = getEntry(this.jzfile, var1 + "/");
- }
-
- if (var2 != 0L) {
- ZipEntry var4 = new ZipEntry(var1, var2);
- freeEntry(this.jzfile, var2);
- return var4;
- } else {
- return null;
- }
- }
- }
-
- private static native long getEntry(long var0, String var2);
-
- private static native void freeEntry(long var0, long var2);
-
- public InputStream getInputStream(ZipEntry var1) throws IOException {
- return this.getInputStream(var1.name);
- }
-
- private InputStream getInputStream(String var1) throws IOException {
- if (var1 == null) {
- throw new NullPointerException("name");
- } else if (this.jzfile == 0L) {
- throw new IllegalStateException("zip file closed");
- } else {
- long var2 = getEntry(this.jzfile, var1);
- if (var2 == 0L) {
- return null;
- } else {
- ZipFileInputStream var4 = new ZipFileInputStream(this.jzfile, var2);
- switch (getMethod(var2)) {
- case 0:
- return var4;
- case 8:
- return new 1(this, var4, this.getInflater());
- default:
- throw new ZipException("invalid compression method");
- }
- }
- }
- }
-
- private static native int getMethod(long var0);
-
- private Inflater getInflater() {
- Vector var1 = this.inflaters;
- synchronized(var1) {
- int var2 = this.inflaters.size();
- if (var2 > 0) {
- Inflater var7 = (Inflater)this.inflaters.remove(var2 - 1);
- var7.reset();
- return var7;
- } else {
- Inflater var3 = new Inflater(true);
- return var3;
- }
- }
- }
-
- private void releaseInflater(Inflater var1) {
- Vector var2 = this.inflaters;
- synchronized(var2) {
- this.inflaters.add(var1);
- }
- }
-
- public String getName() {
- return this.name;
- }
-
- public Enumeration entries() {
- if (this.jzfile == 0L) {
- throw new IllegalStateException("zip file closed");
- } else {
- return new 2(this);
- }
- }
-
- private static native long getNextEntry(long var0, int var2);
-
- public int size() {
- if (this.jzfile == 0L) {
- throw new IllegalStateException("zip file closed");
- } else {
- return this.total;
- }
- }
-
- public void close() throws IOException {
- if (this.jzfile != 0L) {
- long var1 = this.jzfile;
- this.jzfile = 0L;
- close(var1);
- Vector var3 = this.inflaters;
- synchronized(var3) {
- int var4 = this.inflaters.size();
-
- for(int var5 = 0; var5 < var4; ++var5) {
- Inflater var6 = (Inflater)this.inflaters.get(var5);
- var6.end();
- }
- }
- }
-
- }
-
- protected void finalize() throws IOException {
- this.close();
- }
-
- private static native void close(long var0);
-
- private static native int read(long var0, long var2, int var4, byte[] var5, int var6, int var7);
-
- private static native int getCSize(long var0);
-
- private static native int getSize(long var0);
-
- // $FF: synthetic method
- static void access$000(ZipFile var0, Inflater var1) {
- var0.releaseInflater(var1);
- }
-
- // $FF: synthetic method
- static int access$100(ZipFile var0) {
- return var0.total;
- }
-
- // $FF: synthetic method
- static long access$200(ZipFile var0) {
- return var0.jzfile;
- }
-
- // $FF: synthetic method
- static long access$300(long var0, int var2) {
- return getNextEntry(var0, var2);
- }
-
- // $FF: synthetic method
- static void access$400(long var0, long var2) {
- freeEntry(var0, var2);
- }
-
- // $FF: synthetic method
- static int access$500(long var0) {
- return getCSize(var0);
- }
-
- // $FF: synthetic method
- static int access$600(long var0) {
- return getSize(var0);
- }
-
- // $FF: synthetic method
- static int access$700(long var0, long var2, int var4, byte[] var5, int var6, int var7) {
- return read(var0, var2, var4, var5, var6, var7);
- }
-
- static {
- AccessController.doPrivileged(new LoadLibraryAction("zip"));
- initIDs();
- }
- }
-