package o; import java.io.EOFException; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; /* renamed from: o.giU, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15144giU implements giZ { private final Inflater a; private boolean b; private final InterfaceC15142giR c; private int d; public C15144giU(giZ giz, Inflater inflater) { this(C15145giV.a(giz), inflater); } /* JADX INFO: Access modifiers changed from: package-private */ public C15144giU(InterfaceC15142giR interfaceC15142giR, Inflater inflater) { if (interfaceC15142giR == null) { throw new IllegalArgumentException("source == null"); } if (inflater == null) { throw new IllegalArgumentException("inflater == null"); } this.c = interfaceC15142giR; this.a = inflater; } @Override // o.giZ public final long read(giM gim, long j) throws IOException { boolean c; if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j))); } if (this.b) { throw new IllegalStateException("closed"); } if (j == 0) { return 0L; } do { c = c(); try { C15186gjg e = gim.e(1); int inflate = this.a.inflate(e.a, e.c, 2048 - e.c); if (inflate > 0) { e.c += inflate; long j2 = inflate; gim.a += j2; return j2; } if (!this.a.finished() && !this.a.needsDictionary()) { } d(); if (e.g != e.c) { return -1L; } gim.c = e.b(); C15184gje.c(e); return -1L; } catch (DataFormatException e2) { throw new IOException(e2); } } while (!c); throw new EOFException("source exhausted prematurely"); } public final boolean c() throws IOException { if (!this.a.needsInput()) { return false; } d(); if (this.a.getRemaining() != 0) { throw new IllegalStateException("?"); } if (this.c.a()) { return true; } C15186gjg c15186gjg = this.c.b().c; this.d = c15186gjg.c - c15186gjg.g; this.a.setInput(c15186gjg.a, c15186gjg.g, this.d); return false; } private void d() throws IOException { int i = this.d; if (i == 0) { return; } int remaining = i - this.a.getRemaining(); this.d -= remaining; this.c.f(remaining); } @Override // o.giZ public final giY timeout() { return this.c.timeout(); } @Override // o.giZ, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { if (this.b) { return; } this.a.end(); this.b = true; this.c.close(); } }