/** * Get value as two bytes in big endian byte order. * @param value the Java int to convert to bytes * @return the converted int as a byte array in big endian byte order */ public static byte[] getBytes(final int value) { final byte[] result = new byte[2]; putShort(value, result, 0); return result; }
@Override public byte[] getLocalFileDataData() { byte[] content = new byte[BASE_SIZE + padding]; ZipShort.putShort(alignment | (allowMethodChange ? ALLOW_METHOD_MESSAGE_CHANGE_FLAG : 0), content, 0); return content; }
/** * Encodes the set bits in a form suitable for ZIP archives. * * @param buf the output buffer * @param offset * The offset within the output buffer of the first byte to be written. * must be non-negative and no larger than <tt>buf.length-2</tt> */ public void encode(final byte[] buf, final int offset) { ZipShort.putShort((dataDescriptorFlag ? DATA_DESCRIPTOR_FLAG : 0) | (languageEncodingFlag ? UFT8_NAMES_FLAG : 0) | (encryptionFlag ? ENCRYPTION_FLAG : 0) | (strongEncryptionFlag ? STRONG_ENCRYPTION_FLAG : 0) , buf, offset); }
putShort((ze.getPlatform() << 8) | (!hasUsedZip64 ? DATA_DESCRIPTOR_MIN_VERSION : ZIP64_MIN_VERSION), buf, CFH_VERSION_MADE_BY_OFFSET); putShort(versionNeededToExtract(zipMethod, needsZip64Extra, entryMetaData.usesDataDescriptor), buf, CFH_VERSION_NEEDED_OFFSET); getGeneralPurposeBits(!encodable && fallbackToUTF8, entryMetaData.usesDataDescriptor).encode(buf, CFH_GPB_OFFSET); putShort(zipMethod, buf, CFH_METHOD_OFFSET); putShort(nameLen, buf, CFH_FILENAME_LENGTH_OFFSET); putShort(extra.length, buf, CFH_EXTRA_LENGTH_OFFSET); putShort(commentLen, buf, CFH_COMMENT_LENGTH_OFFSET); putShort(ze.getInternalAttributes(), buf, CFH_INTERNAL_ATTRIBUTES_OFFSET);
final boolean dataDescriptor = usesDataDescriptor(zipMethod, phased); putShort(versionNeededToExtract(zipMethod, hasZip64Extra(ze), dataDescriptor), buf, LFH_VERSION_NEEDED_OFFSET); putShort(zipMethod, buf, LFH_METHOD_OFFSET); putShort(nameLen, buf, LFH_FILENAME_LENGTH_OFFSET); putShort(extra.length, buf, LFH_EXTRA_LENGTH_OFFSET);
@Override public byte[] getLocalFileDataData() { byte[] content = new byte[BASE_SIZE + padding]; ZipShort.putShort(alignment | (allowMethodChange ? ALLOW_METHOD_MESSAGE_CHANGE_FLAG : 0), content, 0); return content; }
/** * Get value as two bytes in big endian byte order. * @param value the Java int to convert to bytes * @return the converted int as a byte array in big endian byte order */ public static byte[] getBytes(final int value) { final byte[] result = new byte[2]; putShort(value, result, 0); return result; }
/** * Encodes the set bits in a form suitable for ZIP archives. * * @param buf the output buffer * @param offset * The offset within the output buffer of the first byte to be written. * must be non-negative and no larger than <tt>buf.length-2</tt> */ public void encode(final byte[] buf, final int offset) { ZipShort.putShort((dataDescriptorFlag ? DATA_DESCRIPTOR_FLAG : 0) | (languageEncodingFlag ? UFT8_NAMES_FLAG : 0) | (encryptionFlag ? ENCRYPTION_FLAG : 0) | (strongEncryptionFlag ? STRONG_ENCRYPTION_FLAG : 0) , buf, offset); }
putShort((ze.getPlatform() << 8) | (!hasUsedZip64 ? DATA_DESCRIPTOR_MIN_VERSION : ZIP64_MIN_VERSION), buf, CFH_VERSION_MADE_BY_OFFSET); putShort(versionNeededToExtract(zipMethod, needsZip64Extra, entryMetaData.usesDataDescriptor), buf, CFH_VERSION_NEEDED_OFFSET); getGeneralPurposeBits(!encodable && fallbackToUTF8, entryMetaData.usesDataDescriptor).encode(buf, CFH_GPB_OFFSET); putShort(zipMethod, buf, CFH_METHOD_OFFSET); putShort(nameLen, buf, CFH_FILENAME_LENGTH_OFFSET); putShort(extra.length, buf, CFH_EXTRA_LENGTH_OFFSET); putShort(commentLen, buf, CFH_COMMENT_LENGTH_OFFSET); putShort(ze.getInternalAttributes(), buf, CFH_INTERNAL_ATTRIBUTES_OFFSET);
final boolean dataDescriptor = usesDataDescriptor(zipMethod, phased); putShort(versionNeededToExtract(zipMethod, hasZip64Extra(ze), dataDescriptor), buf, LFH_VERSION_NEEDED_OFFSET); putShort(zipMethod, buf, LFH_METHOD_OFFSET); putShort(nameLen, buf, LFH_FILENAME_LENGTH_OFFSET); putShort(extra.length, buf, LFH_EXTRA_LENGTH_OFFSET);