@Override public byte[] getCentralDirectoryData() { if (data == null) { this.assembleData(); } byte[] b = null; if (data != null) { b = new byte[data.length]; System.arraycopy(data, 0, b, 0, b.length); } return b; }
@Override public byte[] getLocalFileDataData() { return getCentralDirectoryData(); }
@Override public ZipShort getLocalFileDataLength() { return getCentralDirectoryLength(); }
/** * If the stored CRC matches the one of the given name, return the * Unicode name of the given field. * * <p>If the field is null or the CRCs don't match, return null * instead.</p> */ private static String getUnicodeStringIfOriginalMatches(final AbstractUnicodeExtraField f, final byte[] orig) { if (f != null) { final CRC32 crc32 = new CRC32(); crc32.update(orig); final long origCRC32 = crc32.getValue(); if (origCRC32 == f.getNameCRC32()) { try { return ZipEncodingHelper .UTF8_ZIP_ENCODING.decode(f.getUnicodeName()); } catch (final IOException ex) { // UTF-8 unsupported? should be impossible the // Unicode*ExtraField must contain some bad bytes // TODO log this anywhere? return null; } } } return null; }
/** * Doesn't do anything special since this class always uses the * same data in central directory and local file data. */ @Override public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) throws ZipException { parseFromLocalFileData(buffer, offset, length); } }
/** * If the stored CRC matches the one of the given name, return the * Unicode name of the given field. * * <p>If the field is null or the CRCs don't match, return null * instead.</p> */ private static String getUnicodeStringIfOriginalMatches(final AbstractUnicodeExtraField f, final byte[] orig) { if (f != null) { final CRC32 crc32 = new CRC32(); crc32.update(orig); final long origCRC32 = crc32.getValue(); if (origCRC32 == f.getNameCRC32()) { try { return ZipEncodingHelper .UTF8_ZIP_ENCODING.decode(f.getUnicodeName()); } catch (final IOException ex) { // UTF-8 unsupported? should be impossible the // Unicode*ExtraField must contain some bad bytes // TODO log this anywhere? return null; } } } return null; }
/** * Doesn't do anything special since this class always uses the * same data in central directory and local file data. */ @Override public void parseFromCentralDirectoryData(final byte[] buffer, final int offset, final int length) throws ZipException { parseFromLocalFileData(buffer, offset, length); } }
@Override public ZipShort getCentralDirectoryLength() { if (data == null) { assembleData(); } return new ZipShort(data != null ? data.length : 0); }
@Override public ZipShort getLocalFileDataLength() { return getCentralDirectoryLength(); }
@Override public byte[] getLocalFileDataData() { return getCentralDirectoryData(); }
@Override public byte[] getCentralDirectoryData() { if (data == null) { this.assembleData(); } byte[] b = null; if (data != null) { b = new byte[data.length]; System.arraycopy(data, 0, b, 0, b.length); } return b; }
@Override public ZipShort getCentralDirectoryLength() { if (data == null) { assembleData(); } return new ZipShort(data != null ? data.length : 0); }