< prev index next >

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java

Print this page
rev 52302 : 8213031: Enhance jdk.nio.zipfs to support Posix File Permissions
   1 /*
   2  * Copyright (c) 2009, 2014, 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
  23  * questions.
  24  */
  25 
  26 package jdk.nio.zipfs;
  27 
  28 /**
  29  *
  30  * @author Xueming Shen
  31  */
  32 
  33 class ZipConstants {
  34     /*
  35      * Compression methods
  36      */
  37     static final int METHOD_STORED     = 0;
  38     static final int METHOD_DEFLATED   = 8;
  39     static final int METHOD_DEFLATED64 = 9;
  40     static final int METHOD_BZIP2      = 12;
  41     static final int METHOD_LZMA       = 14;
  42     static final int METHOD_LZ77       = 19;
  43     static final int METHOD_AES        = 99;
  44 
  45     /*
  46      * General purpose bit flag
  47      */
  48     static final int FLAG_ENCRYPTED  = 0x01;
  49     static final int FLAG_DATADESCR  = 0x08;    // crc, size and csize in dd
  50     static final int FLAG_USE_UTF8   = 0x800;   // If this bit is set the filename and
  51                                                 // comment fields for this file must be
  52                                                 // encoded using UTF-8.


 215     static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size
 216 
 217     // end of central directory header (END) fields
 218     static final int  ENDSUB(byte[] b) { return SH(b, 8); }  // number of entries on this disk
 219     static final int  ENDTOT(byte[] b) { return SH(b, 10);}  // total number of entries
 220     static final long ENDSIZ(byte[] b) { return LG(b, 12);}  // central directory size
 221     static final long ENDOFF(byte[] b) { return LG(b, 16);}  // central directory offset
 222     static final int  ENDCOM(byte[] b) { return SH(b, 20);}  // size of zip file comment
 223     static final int  ENDCOM(byte[] b, int off) { return SH(b, off + 20);}
 224 
 225     // zip64 end of central directory recoder fields
 226     static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);}  // total number of entries on disk
 227     static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);}  // total number of entries
 228     static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);}  // central directory size
 229     static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);}  // central directory offset
 230     static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);}   // zip64 end offset
 231 
 232     // central directory header (CEN) fields
 233     static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); }
 234     static final int  CENVEM(byte[] b, int pos) { return SH(b, pos + 4); }

 235     static final int  CENVER(byte[] b, int pos) { return SH(b, pos + 6); }
 236     static final int  CENFLG(byte[] b, int pos) { return SH(b, pos + 8); }
 237     static final int  CENHOW(byte[] b, int pos) { return SH(b, pos + 10);}
 238     static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
 239     static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
 240     static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
 241     static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
 242     static final int  CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
 243     static final int  CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
 244     static final int  CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
 245     static final int  CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
 246     static final int  CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
 247     static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}

 248     static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
 249 
 250     /* The END header is followed by a variable length comment of size < 64k. */
 251     static final long END_MAXLEN = 0xFFFF + ENDHDR;
 252     static final int READBLOCKSZ = 128;
 253 }
   1 /*
   2  * Copyright (c) 2009, 2018, 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
  23  * questions.
  24  */
  25 
  26 package jdk.nio.zipfs;
  27 
  28 /**

  29  * @author Xueming Shen
  30  */

  31 class ZipConstants {
  32     /*
  33      * Compression methods
  34      */
  35     static final int METHOD_STORED     = 0;
  36     static final int METHOD_DEFLATED   = 8;
  37     static final int METHOD_DEFLATED64 = 9;
  38     static final int METHOD_BZIP2      = 12;
  39     static final int METHOD_LZMA       = 14;
  40     static final int METHOD_LZ77       = 19;
  41     static final int METHOD_AES        = 99;
  42 
  43     /*
  44      * General purpose bit flag
  45      */
  46     static final int FLAG_ENCRYPTED  = 0x01;
  47     static final int FLAG_DATADESCR  = 0x08;    // crc, size and csize in dd
  48     static final int FLAG_USE_UTF8   = 0x800;   // If this bit is set the filename and
  49                                                 // comment fields for this file must be
  50                                                 // encoded using UTF-8.


 213     static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size
 214 
 215     // end of central directory header (END) fields
 216     static final int  ENDSUB(byte[] b) { return SH(b, 8); }  // number of entries on this disk
 217     static final int  ENDTOT(byte[] b) { return SH(b, 10);}  // total number of entries
 218     static final long ENDSIZ(byte[] b) { return LG(b, 12);}  // central directory size
 219     static final long ENDOFF(byte[] b) { return LG(b, 16);}  // central directory offset
 220     static final int  ENDCOM(byte[] b) { return SH(b, 20);}  // size of zip file comment
 221     static final int  ENDCOM(byte[] b, int off) { return SH(b, off + 20);}
 222 
 223     // zip64 end of central directory recoder fields
 224     static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);}  // total number of entries on disk
 225     static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);}  // total number of entries
 226     static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);}  // central directory size
 227     static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);}  // central directory offset
 228     static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);}   // zip64 end offset
 229 
 230     // central directory header (CEN) fields
 231     static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); }
 232     static final int  CENVEM(byte[] b, int pos) { return SH(b, pos + 4); }
 233     static final int  CENVEM_FA(byte[] b, int pos) { return CH(b, pos + 5); }
 234     static final int  CENVER(byte[] b, int pos) { return SH(b, pos + 6); }
 235     static final int  CENFLG(byte[] b, int pos) { return SH(b, pos + 8); }
 236     static final int  CENHOW(byte[] b, int pos) { return SH(b, pos + 10);}
 237     static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
 238     static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
 239     static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
 240     static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
 241     static final int  CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
 242     static final int  CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
 243     static final int  CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
 244     static final int  CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
 245     static final int  CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
 246     static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
 247     static final int  CENATX_PERMS(byte[] b, int pos) { return SH(b, pos + 40);}
 248     static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
 249 
 250     /* The END header is followed by a variable length comment of size < 64k. */
 251     static final long END_MAXLEN = 0xFFFF + ENDHDR;
 252     static final int READBLOCKSZ = 128;
 253 }
< prev index next >