/** * The actual data to put into local file data - without Header-ID * or length specifier. * @return get the data */ @Override public byte[] getLocalFileDataData() { // CRC will be added later final byte[] data = new byte[getLocalFileDataLength().getValue() - WORD]; System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); final byte[] linkArray = getLinkedFile().getBytes(); // Uses default charset - see class Javadoc // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); System.arraycopy(ZipShort.getBytes(getUserId()), 0, data, 6, 2); System.arraycopy(ZipShort.getBytes(getGroupId()), 0, data, 8, 2); System.arraycopy(linkArray, 0, data, 10, linkArray.length); // CheckStyle:MagicNumber ON crc.reset(); crc.update(data); final long checksum = crc.getValue(); final byte[] result = new byte[data.length + WORD]; System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, WORD); System.arraycopy(data, 0, result, WORD, data.length); return result; }
/** * The actual data to put into local file data - without Header-ID * or length specifier. * @return get the data */ @Override public byte[] getLocalFileDataData() { // CRC will be added later final byte[] data = new byte[getLocalFileDataLength().getValue() - WORD]; System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); final byte[] linkArray = getLinkedFile().getBytes(); // Uses default charset - see class Javadoc // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); System.arraycopy(ZipShort.getBytes(getUserId()), 0, data, 6, 2); System.arraycopy(ZipShort.getBytes(getGroupId()), 0, data, 8, 2); System.arraycopy(linkArray, 0, data, 10, linkArray.length); // CheckStyle:MagicNumber ON crc.reset(); crc.update(data); final long checksum = crc.getValue(); final byte[] result = new byte[data.length + WORD]; System.arraycopy(ZipLong.getBytes(checksum), 0, result, 0, WORD); System.arraycopy(data, 0, result, WORD, data.length); return result; }