Open the next entry from the zip archive, and return its description. If the previous entry wasn't closed, this method will close it.
()
| 139 | * If the previous entry wasn't closed, this method will close it. |
| 140 | */ |
| 141 | public ZipEntry getNextEntry() throws IOException |
| 142 | { |
| 143 | if (crc == null) |
| 144 | throw new IOException("Stream closed."); |
| 145 | if (entry != null) |
| 146 | closeEntry(); |
| 147 | |
| 148 | int header = readLeInt(); |
| 149 | if (header == CENSIG) |
| 150 | { |
| 151 | /* Central Header reached. */ |
| 152 | close(); |
| 153 | return null; |
| 154 | } |
| 155 | if (header != LOCSIG) |
| 156 | throw new ZipException("Wrong Local header signature: " |
| 157 | + Integer.toHexString(header)); |
| 158 | /* skip version */ |
| 159 | readLeShort(); |
| 160 | flags = readLeShort(); |
| 161 | method = readLeShort(); |
| 162 | int dostime = readLeInt(); |
| 163 | int crc = readLeInt(); |
| 164 | csize = readLeInt(); |
| 165 | size = readLeInt(); |
| 166 | int nameLen = readLeShort(); |
| 167 | int extraLen = readLeShort(); |
| 168 | |
| 169 | if (method == ZipEntry.STORED && csize != size) |
| 170 | throw new ZipException("Stored, but compressed != uncompressed"); |
| 171 | |
| 172 | |
| 173 | byte[] buffer = new byte[nameLen]; |
| 174 | readFully(buffer); |
| 175 | String name; |
| 176 | try |
| 177 | { |
| 178 | name = new String(buffer, "UTF-8"); |
| 179 | } |
| 180 | catch (UnsupportedEncodingException uee) |
| 181 | { |
| 182 | throw new Error();//uee); |
| 183 | } |
| 184 | |
| 185 | entry = createZipEntry(name); |
| 186 | entryAtEOF = false; |
| 187 | entry.setMethod(method); |
| 188 | if ((flags & 8) == 0) |
| 189 | { |
| 190 | entry.setCrc(crc & 0xffffffffL); |
| 191 | entry.setSize(size & 0xffffffffL); |
| 192 | entry.setCompressedSize(csize & 0xffffffffL); |
| 193 | } |
| 194 | entry.setDOSTime(dostime); |
| 195 | if (extraLen > 0) |
| 196 | { |
| 197 | byte[] extra = new byte[extraLen]; |
| 198 | readFully(extra); |
nothing calls this directly
no test coverage detected