/* * Read a four-byte int in little-endian order. */ internal static long readIntLE(java.io.RandomAccessFile raf) //throws IOException { int b0 = raf.read(); int b1 = raf.read(); int b2 = raf.read(); int b3 = raf.read(); if (b3 < 0) { throw new java.io.EOFException(); //Messages.getString("archive.3B")); } return(b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)); // ATTENTION: DOES SIGN EXTENSION: IS THIS WANTED? }
/** * Searches for the "End of central dir record", parses * it and positions the stream at the first central directory * record. */ private void positionAtCentralDirectory() //throws IOException { bool found = false; long off = archive.length() - MIN_EOCD_SIZE; long stopSearching = java.lang.Math.max(0L, archive.length() - MAX_EOCD_SIZE); if (off >= 0) { archive.seek(off); byte[] sig = ZipArchiveOutputStream.EOCD_SIG; int curr = archive.read(); while (off >= stopSearching && curr != -1) { if (curr == sig[POS_0]) { curr = archive.read(); if (curr == sig[POS_1]) { curr = archive.read(); if (curr == sig[POS_2]) { curr = archive.read(); if (curr == sig[POS_3]) { found = true; break; } } } } archive.seek(--off); curr = archive.read(); } } if (!found) { throw new java.util.zip.ZipException("archive is not a ZIP archive"); } archive.seek(off + CFD_LOCATOR_OFFSET); byte[] cfdOffset = new byte[WORD]; archive.readFully(cfdOffset); archive.seek(ZipLong.getValue(cfdOffset)); }
public override int read(byte[] b, int off, int len) //throws IOException { { lock (mSharedRaf) { mSharedRaf.seek(mOffset); if (len > mLength - mOffset) { len = (int)(mLength - mOffset); } int count = mSharedRaf.read(b, off, len); if (count > 0) { mOffset += count; return(count); } else { return(-1); } } }