in.mark(tarheader.length);
signatureLength = IOUtils.readFully(in, tarheader);
in.reset();
if (TarArchiveInputStream.matches(tarheader, signatureLength)) {
if (entryEncoding != null) {
return new TarArchiveInputStream(in, entryEncoding);
} else {
return new TarArchiveInputStream(in);
}
}
// COMPRESS-117 - improve auto-recognition
if (signatureLength >= 512) {
TarArchiveInputStream tais = null;
try {
tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));
// COMPRESS-191 - verify the header checksum
if (tais.getNextTarEntry().isCheckSumOK()) {
return new TarArchiveInputStream(in);
}
} catch (Exception e) { // NOPMD
// can generate IllegalArgumentException as well
// as IOException
// autodetection, simply not a TAR