/* * Closes the current ZIP entry and positions to read the next entry. * * @throws IOException * if an {@code IOException} occurs. */ public void closeEntry() // throws IOException { { if (closed) { throw new java.io.IOException("Stream is closed"); //$NON-NLS-1$ } if (currentEntry == null) { return; } if (currentEntry is java.util.jar.JarEntry) { java.util.jar.Attributes temp = ((java.util.jar.JarEntry)currentEntry).getAttributes(); if (temp != null && temp.containsKey("hidden")) //$NON-NLS-1$ { return; } } /* * The following code is careful to leave the ZipInputStream in a * consistent state, even when close() results in an exception. It does * so by: * - pushing bytes back into the source stream * - reading a data descriptor footer from the source stream * - resetting fields that manage the entry being closed */ // Ensure all entry bytes are read java.lang.Exception failure = null; try { skip(java.lang.Long.MAX_VALUE); } catch (java.lang.Exception e) { failure = e; } int inB, outJ; if (currentEntry.compressionMethod == DEFLATED) { inB = inf.getTotalIn(); outJ = inf.getTotalOut(); } else { inB = inRead; outJ = inRead; } int diff = entryIn - inB; // Pushback any required bytes if (diff != 0) { ((java.io.PushbackInputStream)inJ).unread(buf, len - diff, diff); } try { readAndVerifyDataDescriptor(inB, outJ); } catch (java.lang.Exception e) { if (failure == null) // otherwise we're already going to throw { failure = e; } } inf.reset(); lastRead = inRead = entryIn = len = 0; crc.reset(); currentEntry = null; if (failure != null) { if (failure is java.io.IOException) { throw (java.io.IOException)failure; } else if (failure is java.lang.RuntimeException) { throw (java.lang.RuntimeException)failure; } java.lang.AssertionError error = new java.lang.AssertionError(); error.initCause(failure); throw error; } }
/** * Closes the current ZIP entry and positions to read the next entry. * * @throws IOException * if an {@code IOException} occurs. */ public void closeEntry() { // throws IOException { if (closed) { throw new java.io.IOException("Stream is closed"); //$NON-NLS-1$ } if (currentEntry == null) { return; } if (currentEntry is java.util.jar.JarEntry) { java.util.jar.Attributes temp = ((java.util.jar.JarEntry) currentEntry).getAttributes(); if (temp != null && temp.containsKey("hidden")) { //$NON-NLS-1$ return; } } /* * The following code is careful to leave the ZipInputStream in a * consistent state, even when close() results in an exception. It does * so by: * - pushing bytes back into the source stream * - reading a data descriptor footer from the source stream * - resetting fields that manage the entry being closed */ // Ensure all entry bytes are read java.lang.Exception failure = null; try { skip(java.lang.Long.MAX_VALUE); } catch (java.lang.Exception e) { failure = e; } int inB, outJ; if (currentEntry.compressionMethod == DEFLATED) { inB = inf.getTotalIn(); outJ = inf.getTotalOut(); } else { inB = inRead; outJ = inRead; } int diff = entryIn - inB; // Pushback any required bytes if (diff != 0) { ((java.io.PushbackInputStream) inJ).unread(buf, len - diff, diff); } try { readAndVerifyDataDescriptor(inB, outJ); } catch (java.lang.Exception e) { if (failure == null) { // otherwise we're already going to throw failure = e; } } inf.reset(); lastRead = inRead = entryIn = len = 0; crc.reset(); currentEntry = null; if (failure != null) { if (failure is java.io.IOException) { throw (java.io.IOException) failure; } else if (failure is java.lang.RuntimeException) { throw (java.lang.RuntimeException) failure; } java.lang.AssertionError error = new java.lang.AssertionError(); error.initCause(failure); throw error; } }