/* * Internal constructor. Creates a new ZipEntry by reading the * Central Directory Entry from "in", which must be positioned at * the CDE signature. * * On exit, "in" will be positioned at the start of the next entry. */ internal ZipEntry(LittleEndianReader ler, java.io.InputStream inJ) //throws IOException { /* * We're seeing performance issues when we call readShortLE and * readIntLE, so we're going to read the entire header at once * and then parse the results out without using any function calls. * Uglier, but should be much faster. * * Note that some lines look a bit different, because the corresponding * fields or locals are long and so we need to do & 0xffffffffl to avoid * problems induced by sign extension. */ byte[] hdrBuf = ler.hdrBuf; myReadFully(inJ, hdrBuf); long sig = (hdrBuf[0] & 0xff) | ((hdrBuf[1] & 0xff) << 8) | ((hdrBuf[2] & 0xff) << 16) | ((hdrBuf[3] << 24) & 0xffffffffL); if (sig != ZipFile.CENSIG) { throw new java.util.zip.ZipException(); //Messages.getString("archive.3A")); } compressionMethod = (hdrBuf[10] & 0xff) | ((hdrBuf[11] & 0xff) << 8); time = (hdrBuf[12] & 0xff) | ((hdrBuf[13] & 0xff) << 8); modDate = (hdrBuf[14] & 0xff) | ((hdrBuf[15] & 0xff) << 8); crc = (hdrBuf[16] & 0xff) | ((hdrBuf[17] & 0xff) << 8) | ((hdrBuf[18] & 0xff) << 16) | ((hdrBuf[19] << 24) & 0xffffffffL); compressedSize = (hdrBuf[20] & 0xff) | ((hdrBuf[21] & 0xff) << 8) | ((hdrBuf[22] & 0xff) << 16) | ((hdrBuf[23] << 24) & 0xffffffffL); size = (hdrBuf[24] & 0xff) | ((hdrBuf[25] & 0xff) << 8) | ((hdrBuf[26] & 0xff) << 16) | ((hdrBuf[27] << 24) & 0xffffffffL); nameLen = (hdrBuf[28] & 0xff) | ((hdrBuf[29] & 0xff) << 8); int extraLen = (hdrBuf[30] & 0xff) | ((hdrBuf[31] & 0xff) << 8); int commentLen = (hdrBuf[32] & 0xff) | ((hdrBuf[33] & 0xff) << 8); mLocalHeaderRelOffset = (hdrBuf[42] & 0xff) | ((hdrBuf[43] & 0xff) << 8) | ((hdrBuf[44] & 0xff) << 16) | ((hdrBuf[45] << 24) & 0xffffffffL); byte[] nameBytes = new byte[nameLen]; myReadFully(inJ, nameBytes); byte[] commentBytes = null; if (commentLen > 0) { commentBytes = new byte[commentLen]; myReadFully(inJ, commentBytes); } if (extraLen > 0) { extra = new byte[extraLen]; myReadFully(inJ, extra); } try { /* * The actual character set is "IBM Code Page 437". As of * Sep 2006, the Zip spec (APPNOTE.TXT) supports UTF-8. When * bit 11 of the GP flags field is set, the file name and * comment fields are UTF-8. * * TODO: add correct UTF-8 support. */ name = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(commentBytes);//new String(nameBytes, "ISO-8859-1"); if (commentBytes != null) { comment = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(commentBytes);// new String(commentBytes, "ISO-8859-1"); } else { comment = null; } } catch (java.io.UnsupportedEncodingException uee) { throw new java.lang.InternalError(uee.getMessage()); } }
//throws IOException /* * Internal constructor. Creates a new ZipEntry by reading the * Central Directory Entry from "in", which must be positioned at * the CDE signature. * * On exit, "in" will be positioned at the start of the next entry. */ internal ZipEntry(LittleEndianReader ler, java.io.InputStream inJ) { /* * We're seeing performance issues when we call readShortLE and * readIntLE, so we're going to read the entire header at once * and then parse the results out without using any function calls. * Uglier, but should be much faster. * * Note that some lines look a bit different, because the corresponding * fields or locals are long and so we need to do & 0xffffffffl to avoid * problems induced by sign extension. */ byte[] hdrBuf = ler.hdrBuf; myReadFully(inJ, hdrBuf); long sig = (hdrBuf[0] & 0xff) | ((hdrBuf[1] & 0xff) << 8) | ((hdrBuf[2] & 0xff) << 16) | ((hdrBuf[3] << 24) & 0xffffffffL); if (sig != ZipFile.CENSIG) { throw new java.util.zip.ZipException();//Messages.getString("archive.3A")); } compressionMethod = (hdrBuf[10] & 0xff) | ((hdrBuf[11] & 0xff) << 8); time = (hdrBuf[12] & 0xff) | ((hdrBuf[13] & 0xff) << 8); modDate = (hdrBuf[14] & 0xff) | ((hdrBuf[15] & 0xff) << 8); crc = (hdrBuf[16] & 0xff) | ((hdrBuf[17] & 0xff) << 8) | ((hdrBuf[18] & 0xff) << 16) | ((hdrBuf[19] << 24) & 0xffffffffL); compressedSize = (hdrBuf[20] & 0xff) | ((hdrBuf[21] & 0xff) << 8) | ((hdrBuf[22] & 0xff) << 16) | ((hdrBuf[23] << 24) & 0xffffffffL); size = (hdrBuf[24] & 0xff) | ((hdrBuf[25] & 0xff) << 8) | ((hdrBuf[26] & 0xff) << 16) | ((hdrBuf[27] << 24) & 0xffffffffL); nameLen = (hdrBuf[28] & 0xff) | ((hdrBuf[29] & 0xff) << 8); int extraLen = (hdrBuf[30] & 0xff) | ((hdrBuf[31] & 0xff) << 8); int commentLen = (hdrBuf[32] & 0xff) | ((hdrBuf[33] & 0xff) << 8); mLocalHeaderRelOffset = (hdrBuf[42] & 0xff) | ((hdrBuf[43] & 0xff) << 8) | ((hdrBuf[44] & 0xff) << 16) | ((hdrBuf[45] << 24) & 0xffffffffL); byte[] nameBytes = new byte[nameLen]; myReadFully(inJ, nameBytes); byte[] commentBytes = null; if (commentLen > 0) { commentBytes = new byte[commentLen]; myReadFully(inJ, commentBytes); } if (extraLen > 0) { extra = new byte[extraLen]; myReadFully(inJ, extra); } try { /* * The actual character set is "IBM Code Page 437". As of * Sep 2006, the Zip spec (APPNOTE.TXT) supports UTF-8. When * bit 11 of the GP flags field is set, the file name and * comment fields are UTF-8. * * TODO: add correct UTF-8 support. */ name = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(commentBytes);//new String(nameBytes, "ISO-8859-1"); if (commentBytes != null) { comment = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(commentBytes);// new String(commentBytes, "ISO-8859-1"); } else { comment = null; } } catch (java.io.UnsupportedEncodingException uee) { throw new java.lang.InternalError(uee.getMessage()); } }