@Override void readFrom(final byte[] buf, int off, final int len) { if (DATA_SIZE != len) throw new IllegalArgumentException(); setVendorVersion(readUShort(buf, off)); off += 2; final int vendorId = (short) readUShort(buf, off); off += 2; if (VENDOR_ID != vendorId) throw new IllegalArgumentException(); setKeyStrength(keyStrength(buf[off])); // checked off += 1; setMethod(readUShort(buf, off)); // off += 2; }
final int end = off + len; while (off < end) { final int headerId = readUShort(buf, off); off += 2; final int dataSize = readUShort(buf, off); off += 2; final ExtraField ef = ExtraField.create(headerId);
break; rof.readFully(cfh, 4, CFH_MIN_LEN - 4); final int gpbf = readUShort(cfh, 8); final int nameLen = readUShort(cfh, 28); final byte[] name = new byte[nameLen]; rof.readFully(name); entry.setRawPlatform(readUShort(cfh, off) >> 8); off += 2; off += 2; // General Purpose Bit Flags entry.setRawMethod(readUShort(cfh, off)); off += 2; final int extraLen = readUShort(cfh, off); off += 2; final int commentLen = readUShort(cfh, off); off += 2;
@Test public void testUShort() { final int s = readUShort(read, 1); assertEquals(0xaa55, s); writeShort(s, write, 1); writeShort(s, write, 3); writeShort(s, write, 5); writeShort(s, write, 7); assertTrue(Arrays.equals(read, write)); }
rof.readFully(eocdr); int off = 0; diskNo = readUShort(eocdr, off); off += 2; cdDiskNo = readUShort(eocdr, off); off += 2; cdEntriesDisk = readUShort(eocdr, off); off += 2; cdEntries = readUShort(eocdr, off); off += 2; if (0 != diskNo || 0 != cdDiskNo || cdEntriesDisk != cdEntries) cdOffset = readUInt(eocdr, off); off += 4; commentLen = readUShort(eocdr, off);
throw new ZipException(name + " (expected Local File Header)"); fp += LFH_MIN_LEN + readUShort(lfh, LFH_FILE_NAME_LENGTH_OFF) // file name length + readUShort(lfh, LFH_FILE_NAME_LENGTH_OFF + 2); // extra field length ReadOnlyFile erof; try {
if (LFH_SIG != readUInt(lfh, 0)) throw new ZipException("Expected Local File Header!"); final int gpbf = readUShort(lfh, 6); final int nameLen = readUShort(lfh, 26); final byte[] name = new byte[nameLen]; rof.readFully(name); off += 2; // General Purpose Bit Flags entry.setRawMethod(readUShort(lfh, off)); off += 2; final int extraLen = readUShort(lfh, off);