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

173 lines
5.9 KiB
Java

package o;
import java.io.EOFException;
import java.io.IOException;
import java.util.Arrays;
import java.util.zip.CRC32;
import java.util.zip.Inflater;
/* renamed from: o.gil, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C15157gil implements giD {
private final C15171giz a;
private final C15158gim b;
private final Inflater c;
private byte d;
private final CRC32 e;
public C15157gil(giD gid) {
C14957gcv.e(gid, "");
C15171giz c15171giz = new C15171giz(gid);
this.a = c15171giz;
Inflater inflater = new Inflater(true);
this.c = inflater;
this.b = new C15158gim((InterfaceC15149gid) c15171giz, inflater);
this.e = new CRC32();
}
@Override // o.giD
public final long read(C15111ghZ c15111ghZ, long j) throws IOException {
long j2;
C14957gcv.e(c15111ghZ, "");
if (j < 0) {
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)).toString());
}
if (j == 0) {
return 0L;
}
if (this.d == 0) {
if (this.a.a(10L)) {
byte d = this.a.c.d(3L);
boolean z = ((d >> 1) & 1) == 1;
if (z) {
d(this.a.c, 0L, 10L);
}
C15171giz c15171giz = this.a;
if (c15171giz.a(2L)) {
d("ID1ID2", 8075, c15171giz.c.s());
this.a.j(8L);
if (((d >> 2) & 1) == 1) {
if (!this.a.a(2L)) {
throw new EOFException();
}
if (z) {
d(this.a.c, 0L, 2L);
}
long e = giE.e(this.a.c.s());
if (this.a.a(e)) {
if (z) {
j2 = e;
d(this.a.c, 0L, e);
} else {
j2 = e;
}
this.a.j(j2);
} else {
throw new EOFException();
}
}
if (((d >> 3) & 1) == 1) {
long b = this.a.b((byte) 0, 0L, Long.MAX_VALUE);
if (b == -1) {
throw new EOFException();
}
if (z) {
d(this.a.c, 0L, b + 1);
}
this.a.j(b + 1);
}
if (((d >> 4) & 1) == 1) {
long b2 = this.a.b((byte) 0, 0L, Long.MAX_VALUE);
if (b2 == -1) {
throw new EOFException();
}
if (z) {
d(this.a.c, 0L, b2 + 1);
}
this.a.j(b2 + 1);
}
if (z) {
C15171giz c15171giz2 = this.a;
if (c15171giz2.a(2L)) {
d("FHCRC", giE.e(c15171giz2.c.s()), (short) this.e.getValue());
this.e.reset();
} else {
throw new EOFException();
}
}
this.d = (byte) 1;
} else {
throw new EOFException();
}
} else {
throw new EOFException();
}
}
if (this.d == 1) {
long j3 = c15111ghZ.c;
long read = this.b.read(c15111ghZ, j);
if (read != -1) {
d(c15111ghZ, j3, read);
return read;
}
this.d = (byte) 2;
}
if (this.d == 2) {
C15171giz c15171giz3 = this.a;
if (!c15171giz3.a(4L)) {
throw new EOFException();
}
int n = c15171giz3.c.n();
d("CRC", ((Integer) giE.c(new Object[]{Integer.valueOf(n)}, 1193193334, -1193193334, n)).intValue(), (int) this.e.getValue());
C15171giz c15171giz4 = this.a;
if (!c15171giz4.a(4L)) {
throw new EOFException();
}
int n2 = c15171giz4.c.n();
d("ISIZE", ((Integer) giE.c(new Object[]{Integer.valueOf(n2)}, 1193193334, -1193193334, n2)).intValue(), (int) this.c.getBytesWritten());
this.d = (byte) 3;
if (!this.a.j()) {
throw new IOException("gzip finished without exhausting source");
}
}
return -1L;
}
@Override // o.giD
public final C15139giB timeout() {
return this.a.timeout();
}
@Override // o.giD, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
this.b.close();
}
private final void d(C15111ghZ c15111ghZ, long j, long j2) {
C15170giy c15170giy = c15111ghZ.d;
C14957gcv.e(c15170giy);
while (j >= c15170giy.d - c15170giy.e) {
j -= c15170giy.d - c15170giy.e;
c15170giy = c15170giy.a;
C14957gcv.e(c15170giy);
}
while (j2 > 0) {
int min = (int) Math.min(c15170giy.d - r6, j2);
this.e.update(c15170giy.c, (int) (c15170giy.e + j), min);
j2 -= min;
c15170giy = c15170giy.a;
C14957gcv.e(c15170giy);
j = 0;
}
}
private static void d(String str, int i, int i2) {
if (i2 == i) {
return;
}
String format = String.format("%s: actual 0x%08x != expected 0x%08x", Arrays.copyOf(new Object[]{str, Integer.valueOf(i2), Integer.valueOf(i)}, 3));
C14957gcv.c((Object) format, "");
throw new IOException(format);
}
}