/** * Read 8-byte integer from buffer. * * @param buffer * @param offset * @return the 8-byte entry as a long */ public static final long convert64(final byte[] buffer, final int offset) { return ByteUtils.fromLittleEndian(buffer, offset, 8); }
/** * Determine if an archive record indicate End of Archive. End of * archive is indicated by a record that consists entirely of null bytes. * * @param record The record data to check. * @return true if the record data is an End of Archive */ protected boolean isEOFRecord(final byte[] record) { return record == null || ArchiveUtils.isArrayZero(record, recordSize); }
/** {@inheritDoc} */ @Override public void close() throws IOException { in.close(); }
/** * close a zipfile quietly; throw no io fault, do nothing * on a null parameter * @param zipfile file to close, can be null */ public static void closeQuietly(final ZipFile zipfile) { IOUtils.closeQuietly(zipfile); }
@Override public Set<String> getInputStreamCompressorNames() { return Sets.newHashSet(GZIP, BROTLI, BZIP2, XZ, LZMA, PACK200, DEFLATE, SNAPPY_RAW, SNAPPY_FRAMED, Z, LZ4_BLOCK, LZ4_FRAMED, ZSTANDARD, DEFLATE64); }
/** * @since 1.17 */ @Override public long getCompressedCount() { return countingStream.getBytesRead() - unreadBytes; }
/** * Reads a byte array from the stream * @throws IOException if the underlying stream throws or the * stream is exhausted and the Checksum doesn't match the expected * value */ @Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public void write(final byte[] b) throws IOException { write(b, 0, b.length); } @Override
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); } @Override
@Override public SeekableByteChannel truncate(long newSize) { if (size > newSize) { size = (int) newSize; } repositionIfNecessary(); return this; }
/** * Get value as two bytes in big endian byte order. * @return the value as a a two byte array in big endian byte order */ public byte[] getBytes() { final byte[] result = new byte[2]; ByteUtils.toLittleEndian(result, value, 0, 2); return result; }
/** {@inheritDoc} */ @Override public long skip(final long n) throws IOException { return IOUtils.skip(in, n); }
/** * @since 1.17 */ @Override public long getCompressedCount() { return bin.getBytesRead(); }
/** * @since 1.17 */ @Override public long getCompressedCount() { return in.getBytesRead(); }
/** * Reads the given byte array as a little endian long. * @param bytes the byte array to convert * @return the number read */ public static long fromLittleEndian(byte[] bytes) { return fromLittleEndian(bytes, 0, bytes.length); }
@Override public long skip(final long n) throws IOException { // Can't really skip, we have to hash everything to verify the checksum if (read() >= 0) { return 1; } return 0; }
/** * @since 1.17 */ @Override public long getCompressedCount() { return in.getBytesRead(); }
/** * @since 1.17 */ @Override public long getCompressedCount() { return in.getBytesRead(); }
/** * Helper method to get the value as a Java long from four bytes starting at given array offset * @param bytes the array of bytes * @param offset the offset to start * @return the corresponding Java long value */ public static long getValue(final byte[] bytes, final int offset) { return ByteUtils.fromLittleEndian(bytes, offset, 4); }
/** * @since 1.17 */ @Override public long getCompressedCount() { return countingStream.getBytesRead(); }