private long readBinaryLong(int length, bool swapHalfWord) //throws IOException { byte [] tmp = new byte[length]; readFully(tmp, 0, tmp.Length); return(CpioUtil.byteArray2long(tmp, swapHalfWord)); }
/** * Reads the next CPIO file entry and positions stream at the beginning of * the entry data. * * @return the CPIOArchiveEntry just read * @throws IOException * if an I/O error has occurred or if a CPIO file error has * occurred */ public CpioArchiveEntry getNextCPIOEntry() //throws IOException { ensureOpen(); if (this.entry != null) { closeEntry(); } byte [] magic = new byte[2]; readFully(magic, 0, magic.Length); if (CpioUtil.byteArray2long(magic, false) == CpioConstants.MAGIC_OLD_BINARY) { this.entry = readOldBinaryEntry(false); } else if (CpioUtil.byteArray2long(magic, true) == CpioConstants.MAGIC_OLD_BINARY) { this.entry = readOldBinaryEntry(true); } else { byte [] more_magic = new byte[4]; readFully(more_magic, 0, more_magic.Length); byte [] tmp = new byte[6]; java.lang.SystemJ.arraycopy(magic, 0, tmp, 0, magic.Length); java.lang.SystemJ.arraycopy(more_magic, 0, tmp, magic.Length, more_magic.Length); String magicString = ArchiveUtils.toAsciiString(tmp); if (magicString.equals(CpioConstants.MAGIC_NEW)) { this.entry = readNewEntry(false); } else if (magicString.equals(CpioConstants.MAGIC_NEW_CRC)) { this.entry = readNewEntry(true); } else if (magicString.equals(CpioConstants.MAGIC_OLD_ASCII)) { this.entry = readOldAsciiEntry(); } else { throw new java.io.IOException("Unknown magic [" + magicString + "]. Occured at byte: " + getBytesRead()); } } this.entryBytesRead = 0; this.entryEOF = false; this.crc = 0; if (this.entry.getName().equals(CpioConstants.CPIO_TRAILER)) { this.entryEOF = true; return(null); } return(this.entry); }