3909N/A * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class is used to read entries from a zip file. 0N/A * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor 0N/A * or method in this class will cause a {@link NullPointerException} to be 0N/A * @author David Connelly 6329N/A private final boolean locsig;
// if zip file starts with LOCSIG (usually true) 0N/A * Mode flag to open a zip file for reading. 0N/A * Mode flag to open a zip file and mark it for deletion. The file will be 0N/A * deleted some time between the moment that it is opened and the moment 0N/A * that it is closed, but its contents will remain accessible via the 0N/A * <tt>ZipFile</tt> object until either the close method is invoked or the 0N/A * virtual machine exits. 2227N/A // A system prpperty to disable mmap use to avoid vm crash when 2227N/A // in-use zip file is accidently overwritten by others. 0N/A * Opens a zip file for reading. 1107N/A * <p>First, if there is a security manager, its <code>checkRead</code> 1107N/A * method is called with the <code>name</code> argument as its argument 1107N/A * to ensure the read is allowed. 1107N/A * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to 1107N/A * decode the entry names and comments. 0N/A * @param name the name of the zip file 0N/A * @throws ZipException if a ZIP format error has occurred 0N/A * @throws IOException if an I/O error has occurred 0N/A * @throws SecurityException if a security manager exists and its 0N/A * <code>checkRead</code> method doesn't allow read access to the file. 0N/A * @see SecurityManager#checkRead(java.lang.String) 0N/A * Opens a new <code>ZipFile</code> to read from the specified 0N/A * <code>File</code> object in the specified mode. The mode argument 0N/A * must be either <tt>OPEN_READ</tt> or <tt>OPEN_READ | OPEN_DELETE</tt>. 0N/A * <p>First, if there is a security manager, its <code>checkRead</code> 0N/A * method is called with the <code>name</code> argument as its argument to 0N/A * ensure the read is allowed. 1107N/A * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to 1107N/A * decode the entry names and comments 0N/A * @param file the ZIP file to be opened for reading 0N/A * @param mode the mode in which the file is to be opened 0N/A * @throws ZipException if a ZIP format error has occurred 0N/A * @throws IOException if an I/O error has occurred 0N/A * @throws SecurityException if a security manager exists and 0N/A * its <code>checkRead</code> method 0N/A * doesn't allow read access to the file, 0N/A * or its <code>checkDelete</code> method doesn't allow deleting 0N/A * the file when the <tt>OPEN_DELETE</tt> flag is set. 0N/A * @throws IllegalArgumentException if the <tt>mode</tt> argument is invalid 0N/A * @see SecurityManager#checkRead(java.lang.String) 1107N/A * Opens a ZIP file for reading given the specified File object. 1107N/A * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to 1107N/A * decode the entry names and comments. 1107N/A * @param file the ZIP file to be opened for reading 1107N/A * @throws ZipException if a ZIP format error has occurred 1107N/A * @throws IOException if an I/O error has occurred 1107N/A * Opens a new <code>ZipFile</code> to read from the specified 1107N/A * <code>File</code> object in the specified mode. The mode argument 1107N/A * must be either <tt>OPEN_READ</tt> or <tt>OPEN_READ | OPEN_DELETE</tt>. 1107N/A * <p>First, if there is a security manager, its <code>checkRead</code> 1107N/A * method is called with the <code>name</code> argument as its argument to 1107N/A * ensure the read is allowed. 1107N/A * @param file the ZIP file to be opened for reading 1107N/A * @param mode the mode in which the file is to be opened 1190N/A * the {@linkplain java.nio.charset.Charset charset} to 1107N/A * be used to decode the ZIP entry name and comment that are not 1107N/A * encoded by using UTF-8 encoding (indicated by entry's general 1107N/A * @throws ZipException if a ZIP format error has occurred 1107N/A * @throws IOException if an I/O error has occurred 1107N/A * @throws SecurityException 1107N/A * if a security manager exists and its <code>checkRead</code> 1107N/A * method doesn't allow read access to the file,or its 1107N/A * <code>checkDelete</code> method doesn't allow deleting the 1107N/A * file when the <tt>OPEN_DELETE</tt> flag is set 1107N/A * @throws IllegalArgumentException if the <tt>mode</tt> argument is invalid 1107N/A * @see SecurityManager#checkRead(java.lang.String) 1107N/A * Opens a zip file for reading. 1107N/A * <p>First, if there is a security manager, its <code>checkRead</code> 1107N/A * method is called with the <code>name</code> argument as its argument 1107N/A * to ensure the read is allowed. 1107N/A * @param name the name of the zip file 1190N/A * the {@linkplain java.nio.charset.Charset charset} to 1107N/A * be used to decode the ZIP entry name and comment that are not 1107N/A * encoded by using UTF-8 encoding (indicated by entry's general 1107N/A * @throws ZipException if a ZIP format error has occurred 1107N/A * @throws IOException if an I/O error has occurred 1107N/A * @throws SecurityException 1107N/A * if a security manager exists and its <code>checkRead</code> 1107N/A * method doesn't allow read access to the file 1107N/A * @see SecurityManager#checkRead(java.lang.String) 0N/A * Opens a ZIP file for reading given the specified File object. 0N/A * @param file the ZIP file to be opened for reading 1190N/A * The {@linkplain java.nio.charset.Charset charset} to be 1107N/A * used to decode the ZIP entry name and comment (ignored if 1107N/A * encoding bit</a> of the ZIP entry's general purpose bit 1107N/A * @throws ZipException if a ZIP format error has occurred 0N/A * @throws IOException if an I/O error has occurred 1332N/A * Returns the zip file comment, or null if none. 1332N/A * @return the comment string for the zip file, or null if none 1332N/A * @throws IllegalStateException if the zip file has been closed 0N/A * Returns the zip file entry for the specified name, or null 0N/A * @param name the name of the entry 0N/A * @return the zip file entry, or null if not found 0N/A * @throws IllegalStateException if the zip file has been closed 0N/A synchronized (
this) {
0N/A // freeEntry releases the C jzentry struct. 4023N/A // the outstanding inputstreams that need to be closed, 4023N/A // mapped to the inflater objects they use. 0N/A * Returns an input stream for reading the contents of the specified 0N/A * <p> Closing this ZIP file will, in turn, close all input 0N/A * streams that have been returned by invocations of this method. 0N/A * @param entry the zip file entry 0N/A * @return the input stream for reading the contents of the specified 0N/A * @throws ZipException if a ZIP format error has occurred 0N/A * @throws IOException if an I/O error has occurred 0N/A * @throws IllegalStateException if the zip file has been closed 0N/A synchronized (
this) {
3235N/A // MORE: Compute good size for inflater stream: 4023N/A // Override fill() method to provide an extra "dummy" byte 4023N/A // at the end of the input stream. This is required when 4023N/A // using the "nowrap" Inflater option. 0N/A * Gets an inflater from the list of available inflaters or allocates 0N/A * Releases the specified inflater to the list of available inflaters. 0N/A // List of available Inflater objects for decompression 0N/A * Returns the path name of the ZIP file. 0N/A * @return the path name of the ZIP file 0N/A * Returns an enumeration of the ZIP file entries. 0N/A * @return an enumeration of the ZIP file entries 0N/A * @throws IllegalStateException if the zip file has been closed 0N/A * Returns the number of entries in the ZIP file. 0N/A * @return the number of entries in the ZIP file 0N/A * @throws IllegalStateException if the zip file has been closed 0N/A * Closes the ZIP file. 0N/A * <p> Closing this ZIP file will close all of the input streams 0N/A * previously returned by invocations of the {@link #getInputStream 0N/A * getInputStream} method. 0N/A * @throws IOException if an I/O error has occurred 4023N/A // Close streams, release their inflaters 4023N/A // Release cached inflaters 0N/A // Close the zip file 4023N/A * Ensures that the system resources held by this ZipFile object are 4023N/A * released when there are no more references to it. 0N/A * Since the time when GC would invoke this method is undetermined, 0N/A * it is strongly recommended that applications invoke the <code>close</code> 0N/A * method as soon they have finished accessing this <code>ZipFile</code>. 0N/A * This will prevent holding up system resources for an undetermined 0N/A * @throws IOException if an I/O error has occurred 0N/A * @see java.util.zip.ZipFile#close() 0N/A * Inner class implementing the input stream used to read a 0N/A * (possibly compressed) zip file entry. 0N/A protected long jzentry;
// address of jzentry data 0N/A private long pos;
// current position within entry data 0N/A protected long rem;
// number of remaining bytes within entry 0N/A protected long size;
// uncompressed size of this entry 0N/A byte[] b =
new byte[
1];
6329N/A * Returns {@code true} if, and only if, the zip file begins with {@code 1107N/A // access to the native zentry object