< prev index next >

src/java.base/share/classes/java/util/zip/ZipUtils.java

Print this page


   1 /*
   2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 259     static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
 260     static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
 261     static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
 262     static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
 263     static final int  CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
 264     static final int  CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
 265     static final int  CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
 266     static final int  CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
 267     static final int  CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
 268     static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
 269     static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
 270 
 271     // The END header is followed by a variable length comment of size < 64k.
 272     static final long END_MAXLEN = 0xFFFF + ENDHDR;
 273     static final int READBLOCKSZ = 128;
 274 
 275     /**
 276      * Loads zip native library, if not already laoded
 277      */
 278     static void loadLibrary() {
 279         jdk.internal.loader.BootLoader.loadLibrary("zip");
 280     }
 281 
 282     private static final Unsafe unsafe = Unsafe.getUnsafe();
 283 
 284     private static final long byteBufferArrayOffset = unsafe.objectFieldOffset(ByteBuffer.class, "hb");
 285     private static final long byteBufferOffsetOffset = unsafe.objectFieldOffset(ByteBuffer.class, "offset");
 286 
 287     static byte[] getBufferArray(ByteBuffer byteBuffer) {
 288         return (byte[]) unsafe.getReference(byteBuffer, byteBufferArrayOffset);
 289     }
 290 
 291     static int getBufferOffset(ByteBuffer byteBuffer) {
 292         return unsafe.getInt(byteBuffer, byteBufferOffsetOffset);
 293     }
 294 }
   1 /*
   2  * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 259     static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
 260     static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
 261     static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
 262     static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
 263     static final int  CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
 264     static final int  CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
 265     static final int  CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
 266     static final int  CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
 267     static final int  CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
 268     static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
 269     static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
 270 
 271     // The END header is followed by a variable length comment of size < 64k.
 272     static final long END_MAXLEN = 0xFFFF + ENDHDR;
 273     static final int READBLOCKSZ = 128;
 274 
 275     /**
 276      * Loads zip native library, if not already laoded
 277      */
 278     static void loadLibrary() {
 279         sun.security.action.LoadLibraryAction.privilegedLoadLibrary("zip");
 280     }
 281 
 282     private static final Unsafe unsafe = Unsafe.getUnsafe();
 283 
 284     private static final long byteBufferArrayOffset = unsafe.objectFieldOffset(ByteBuffer.class, "hb");
 285     private static final long byteBufferOffsetOffset = unsafe.objectFieldOffset(ByteBuffer.class, "offset");
 286 
 287     static byte[] getBufferArray(ByteBuffer byteBuffer) {
 288         return (byte[]) unsafe.getReference(byteBuffer, byteBufferArrayOffset);
 289     }
 290 
 291     static int getBufferOffset(ByteBuffer byteBuffer) {
 292         return unsafe.getInt(byteBuffer, byteBufferOffsetOffset);
 293     }
 294 }
< prev index next >