jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
changeset 38467 172e0c9007a6
parent 38466 4bcf5f2bb351
child 39310 fed59f4021c8
equal deleted inserted replaced
38466:4bcf5f2bb351 38467:172e0c9007a6
   806             close();
   806             close();
   807         }
   807         }
   808     }
   808     }
   809 
   809 
   810     /**
   810     /**
   811      * Returns an array of strings representing the names of all entries
   811      * Returns the names of all non-directory entries that begin with
   812      * that begin with "META-INF/" (case ignored). This method is used
   812      * "META-INF/" (case ignored). This method is used in JarFile, via
   813      * in JarFile, via SharedSecrets, as an optimization when looking up
   813      * SharedSecrets, as an optimization when looking up manifest and
   814      * manifest and signature file entries. Returns null if no entries
   814      * signature file entries. Returns null if no entries were found.
   815      * were found.
       
   816      */
   815      */
   817     private String[] getMetaInfEntryNames() {
   816     private String[] getMetaInfEntryNames() {
   818         synchronized (this) {
   817         synchronized (this) {
   819             ensureOpen();
   818             ensureOpen();
   820             if (zsrc.metanames == null) {
   819             if (zsrc.metanames == null) {
  1302                 && (name[off++] | 0x20) == 'n'
  1301                 && (name[off++] | 0x20) == 'n'
  1303                 && (name[off++] | 0x20) == 'f'
  1302                 && (name[off++] | 0x20) == 'f'
  1304                 && (name[off]         ) == '/';
  1303                 && (name[off]         ) == '/';
  1305         }
  1304         }
  1306 
  1305 
  1307         /*
  1306         /**
  1308          * Counts the number of CEN headers in a central directory extending
  1307          * Returns the number of CEN headers in a central directory.
  1309          * from BEG to END.  Might return a bogus answer if the zip file is
  1308          * Will not throw, even if the zip file is corrupt.
  1310          * corrupt, but will not crash.
  1309          *
       
  1310          * @param cen copy of the bytes in a zip file's central directory
       
  1311          * @param size number of bytes in central directory
  1311          */
  1312          */
  1312         static int countCENHeaders(byte[] cen, int end) {
  1313         private static int countCENHeaders(byte[] cen, int size) {
  1313             int count = 0;
  1314             int count = 0;
  1314             int pos = 0;
  1315             for (int p = 0;
  1315             while (pos + CENHDR <= end) {
  1316                  p + CENHDR <= size;
       
  1317                  p += CENHDR + CENNAM(cen, p) + CENEXT(cen, p) + CENCOM(cen, p))
  1316                 count++;
  1318                 count++;
  1317                 pos += (CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos));
       
  1318             }
       
  1319             return count;
  1319             return count;
  1320         }
  1320         }
  1321     }
  1321     }
  1322 }
  1322 }