what-the-bank/sources/o/C15143giT.java

138 lines
4.0 KiB
Java

package o;
import java.io.EOFException;
import java.io.IOException;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
/* renamed from: o.giT, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public final class C15143giT implements giZ {
private final InterfaceC15142giR a;
private final Inflater b;
private final C15144giU c;
private int e = 0;
private final CRC32 d = new CRC32();
public C15143giT(giZ giz) {
if (giz == null) {
throw new IllegalArgumentException("source == null");
}
Inflater inflater = new Inflater(true);
this.b = inflater;
InterfaceC15142giR a = C15145giV.a(giz);
this.a = a;
this.c = new C15144giU(a, inflater);
}
@Override // o.giZ
public final long read(giM gim, long j) throws IOException {
long j2;
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
}
if (j == 0) {
return 0L;
}
if (this.e == 0) {
this.a.j(10L);
byte b = this.a.b().b(3L);
boolean z = ((b >> 1) & 1) == 1;
if (z) {
c(this.a.b(), 0L, 10L);
}
e("ID1ID2", 8075, this.a.o());
this.a.f(8L);
if (((b >> 2) & 1) == 1) {
this.a.j(2L);
if (z) {
c(this.a.b(), 0L, 2L);
}
long c = C15183gjd.c(this.a.b().o());
this.a.j(c);
if (z) {
j2 = c;
c(this.a.b(), 0L, c);
} else {
j2 = c;
}
this.a.f(j2);
}
if (((b >> 3) & 1) == 1) {
long c2 = this.a.c((byte) 0);
if (c2 == -1) {
throw new EOFException();
}
if (z) {
c(this.a.b(), 0L, c2 + 1);
}
this.a.f(c2 + 1);
}
if (((b >> 4) & 1) == 1) {
long c3 = this.a.c((byte) 0);
if (c3 == -1) {
throw new EOFException();
}
if (z) {
c(this.a.b(), 0L, c3 + 1);
}
this.a.f(c3 + 1);
}
if (z) {
e("FHCRC", this.a.m(), (short) this.d.getValue());
this.d.reset();
}
this.e = 1;
}
if (this.e == 1) {
long j3 = gim.a;
long read = this.c.read(gim, j);
if (read != -1) {
c(gim, j3, read);
return read;
}
this.e = 2;
}
if (this.e == 2) {
e("CRC", this.a.n(), (int) this.d.getValue());
e("ISIZE", this.a.n(), this.b.getTotalOut());
this.e = 3;
if (!this.a.a()) {
throw new IOException("gzip finished without exhausting source");
}
}
return -1L;
}
@Override // o.giZ
public final giY timeout() {
return this.a.timeout();
}
@Override // o.giZ, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
this.c.close();
}
private void c(giM gim, long j, long j2) {
C15186gjg c15186gjg = gim.c;
while (j >= c15186gjg.c - c15186gjg.g) {
j -= c15186gjg.c - c15186gjg.g;
c15186gjg = c15186gjg.b;
}
while (j2 > 0) {
int min = (int) Math.min(c15186gjg.c - r6, j2);
this.d.update(c15186gjg.a, (int) (c15186gjg.g + j), min);
j2 -= min;
c15186gjg = c15186gjg.b;
j = 0;
}
}
private static void e(String str, int i, int i2) throws IOException {
if (i2 != i) {
throw new IOException(String.format("%s: actual 0x%08x != expected 0x%08x", str, Integer.valueOf(i2), Integer.valueOf(i)));
}
}
}