/** * Helper method called when it is determined that the target buffer can not * hold all data to copy or uncompress */ protected void _reportArrayOverflow(byte[] targetBuffer, int outPtr, int dataLen) throws LZFException { throw new LZFException("Target buffer too small ("+targetBuffer.length+"): can not copy/uncompress " +dataLen+" bytes to offset "+outPtr); } }
/** * Helper method called when it is determined that the target buffer can not * hold all data to copy or uncompress */ protected void _reportArrayOverflow(byte[] targetBuffer, int outPtr, int dataLen) throws LZFException { throw new LZFException("Target buffer too small ("+targetBuffer.length+"): can not copy/uncompress " +dataLen+" bytes to offset "+outPtr); } }
/** * Helper method called when it is determined that the target buffer can not * hold all data to copy or uncompress */ protected void _reportArrayOverflow(byte[] targetBuffer, int outPtr, int dataLen) throws LZFException { throw new LZFException("Target buffer too small ("+targetBuffer.length+"): can not copy/uncompress " +dataLen+" bytes to offset "+outPtr); } }
protected void _reportCorruptHeader() throws LZFException { throw new LZFException("Corrupt input data, block did not start with 2 byte signature ('ZV') followed by type byte, 2-byte length)"); }
protected void _reportCorruptHeader() throws LZFException { throw new LZFException("Corrupt input data, block did not start with 2 byte signature ('ZV') followed by type byte, 2-byte length)"); }
protected void _reportCorruptHeader() throws LZFException { throw new LZFException("Corrupt input data, block did not start with 2 byte signature ('ZV') followed by type byte, 2-byte length)"); }
protected final static void skipFully(final InputStream is, int amount) throws IOException { final int orig = amount; while (amount > 0) { long skipped = is.skip(amount); if (skipped <= 0) { throw new LZFException("Input problem: failed to skip "+orig+" bytes in input stream, only skipped " +(orig-amount)); } amount -= (int) skipped; } }
protected void _reportBadBlockType(byte[] comp, int nextOffset, int len, int type) throws IOException { throw new LZFException("Bad block: unrecognized type 0x"+Integer.toHexString(type & 0xFF) +" (at "+(nextOffset-1)+"/"+len+")"); } }
protected final static void skipFully(final InputStream is, int amount) throws IOException { final int orig = amount; while (amount > 0) { long skipped = is.skip(amount); if (skipped <= 0) { throw new LZFException("Input problem: failed to skip "+orig+" bytes in input stream, only skipped " +(orig-amount)); } amount -= (int) skipped; } }
protected final static void skipFully(final InputStream is, int amount) throws IOException { final int orig = amount; while (amount > 0) { long skipped = is.skip(amount); if (skipped <= 0) { throw new LZFException("Input problem: failed to skip "+orig+" bytes in input stream, only skipped " +(orig-amount)); } amount -= (int) skipped; } }
protected void _reportBadBlockType(byte[] comp, int nextOffset, int len, int type) throws IOException { throw new LZFException("Bad block: unrecognized type 0x"+Integer.toHexString(type & 0xFF) +" (at "+(nextOffset-1)+"/"+len+")"); } }
protected void _reportBadBlockType(byte[] comp, int nextOffset, int len, int type) throws IOException { throw new LZFException("Bad block: unrecognized type 0x"+Integer.toHexString(type & 0xFF) +" (at "+(nextOffset-1)+"/"+len+")"); } }
protected final static void readFully(InputStream is, boolean compressed, byte[] outputBuffer, int offset, int len) throws IOException { int left = len; while (left > 0) { int count = is.read(outputBuffer, offset, left); if (count < 0) { // EOF not allowed here throw new LZFException("EOF in "+len+" byte (" +(compressed ? "" : "un")+"compressed) block: could only read " +(len-left)+" bytes"); } offset += count; left -= count; } }
protected final static void readFully(InputStream is, boolean compressed, byte[] outputBuffer, int offset, int len) throws IOException { int left = len; while (left > 0) { int count = is.read(outputBuffer, offset, left); if (count < 0) { // EOF not allowed here throw new LZFException("EOF in "+len+" byte (" +(compressed ? "" : "un")+"compressed) block: could only read " +(len-left)+" bytes"); } offset += count; left -= count; } }
protected final static void readFully(InputStream is, boolean compressed, byte[] outputBuffer, int offset, int len) throws IOException { int left = len; while (left > 0) { int count = is.read(outputBuffer, offset, left); if (count < 0) { // EOF not allowed here throw new LZFException("EOF in "+len+" byte (" +(compressed ? "" : "un")+"compressed) block: could only read " +(len-left)+" bytes"); } offset += count; left -= count; } }
protected void _reportBadHeader(byte[] comp, int nextOffset, int len, int relative) throws IOException { char exp = (relative == 0) ? 'Z' : 'V'; --nextOffset; throw new LZFException("Bad block: byte #"+relative+" of block header not '" +exp+"' (0x"+Integer.toHexString(exp) +") but 0x"+Integer.toHexString(comp[nextOffset] & 0xFF) +" (at "+(nextOffset-1)+"/"+(len)+")"); }
protected void _reportBadHeader(byte[] comp, int nextOffset, int len, int relative) throws IOException { char exp = (relative == 0) ? 'Z' : 'V'; --nextOffset; throw new LZFException("Bad block: byte #"+relative+" of block header not '" +exp+"' (0x"+Integer.toHexString(exp) +") but 0x"+Integer.toHexString(comp[nextOffset] & 0xFF) +" (at "+(nextOffset-1)+"/"+(len)+")"); }
protected void _reportBadHeader(byte[] comp, int nextOffset, int len, int relative) throws IOException { char exp = (relative == 0) ? 'Z' : 'V'; --nextOffset; throw new LZFException("Bad block: byte #"+relative+" of block header not '" +exp+"' (0x"+Integer.toHexString(exp) +") but 0x"+Integer.toHexString(comp[nextOffset] & 0xFF) +" (at "+(nextOffset-1)+"/"+(len)+")"); }
throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): did not start with 'ZV' signature bytes"); ptr += 7; } else { // unknown... CRC-32 would be 2, but that's not implemented by cli tool throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): unrecognized block type "+(type & 0xFF)); throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): truncated block header"); throw new LZFException("Corrupt input data: block #"+blockNr+" extends "+(data.length - ptr)+" beyond end of input");
throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): did not start with 'ZV' signature bytes"); ptr += 7; } else { // unknown... CRC-32 would be 2, but that's not implemented by cli tool throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): unrecognized block type "+(type & 0xFF)); throw new LZFException("Corrupt input data, block #"+blockNr+" (at offset "+ptr+"): truncated block header"); throw new LZFException("Corrupt input data: block #"+blockNr+" extends "+(data.length - ptr)+" beyond end of input");