use of it.geosolutions.io.input.adapter.InputStreamAdapter in project imageio-ext by geosolutions-it.
the class GZIPImageInputStream method readTrailer.
/**
* Reads GZIP member trailer.
*/
private void readTrailer() throws IOException {
InputStream in = new InputStreamAdapter(this.iis);
int n = inf.getRemaining();
if (n > 0) {
in = new SequenceInputStream(new ByteArrayInputStream(buf, len - n, n), in);
}
// Uses left-to-right evaluation order
if ((readUInt(in) != crc.getValue()) || // should be preferred)
(readUInt(in) != (inf.getTotalOut() & 0xffffffffL)))
throw new IOException("Corrupt GZIP trailer");
}
use of it.geosolutions.io.input.adapter.InputStreamAdapter in project imageio-ext by geosolutions-it.
the class GZIPImageInputStream method readHeader.
/**
* Reads GZIP member header.
*/
private void readHeader() throws IOException {
CheckedInputStream in = new CheckedInputStream(new InputStreamAdapter(this.iis), crc);
crc.reset();
// Check header magic
if (readUShort(in) != GZIP_MAGIC) {
throw new IOException("Not in GZIP format");
}
// Check compression method
if (readUByte(in) != 8) {
throw new IOException("Unsupported compression method");
}
// Read flags
int flg = readUByte(in);
// Skip MTIME, XFL, and OS fields
skipBytes(in, 6);
// Skip optional extra field
if ((flg & FEXTRA) == FEXTRA) {
skipBytes(in, readUShort(in));
}
// Skip optional eraf name
if ((flg & FNAME) == FNAME) {
while (readUByte(in) != 0) ;
}
// Skip optional eraf comment
if ((flg & FCOMMENT) == FCOMMENT) {
while (readUByte(in) != 0) ;
}
// Check optional header CRC
if ((flg & FHCRC) == FHCRC) {
int v = (int) crc.getValue() & 0xffff;
if (readUShort(in) != v) {
throw new IOException("Corrupt GZIP header");
}
}
}
Aggregations