package o; import com.google.common.primitives.UnsignedBytes; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.gjh, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15187gjh implements InterfaceC15142giR { private boolean a; public final giZ b; public final giM c; private C15187gjh(giZ giz, giM gim) { if (giz == null) { throw new IllegalArgumentException("source == null"); } this.c = gim; this.b = giz; } public C15187gjh(giZ giz) { this(giz, new giM()); } @Override // o.giZ public final long read(giM gim, long j) throws IOException { if (gim == null) { throw new IllegalArgumentException("sink == null"); } if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j))); } if (this.a) { throw new IllegalStateException("closed"); } if (this.c.a == 0 && this.b.read(this.c, 2048L) == -1) { return -1L; } return this.c.read(gim, Math.min(j, this.c.a)); } @Override // o.InterfaceC15142giR public final void j(long j) throws IOException { if (!a(j)) { throw new EOFException(); } } @Override // o.InterfaceC15142giR public final boolean a(long j) throws IOException { if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j))); } if (this.a) { throw new IllegalStateException("closed"); } while (this.c.a < j) { if (this.b.read(this.c, 2048L) == -1) { return false; } } return true; } @Override // o.InterfaceC15142giR public final byte[] j() throws IOException { this.c.d(this.b); return this.c.j(); } @Override // o.InterfaceC15142giR public final String p() throws IOException { long c = c((byte) 10); if (c == -1) { giM gim = new giM(); giM gim2 = this.c; gim2.d(gim, 0L, Math.min(32L, gim2.a)); StringBuilder sb = new StringBuilder("\\n not found: size="); sb.append(this.c.a); sb.append(" content="); sb.append(new giP(gim.j()).b()); sb.append("..."); throw new EOFException(sb.toString()); } return this.c.c(c); } @Override // o.InterfaceC15142giR public final void f(long j) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } while (j > 0) { if (this.c.a == 0 && this.b.read(this.c, 2048L) == -1) { throw new EOFException(); } long min = Math.min(j, this.c.a); this.c.f(min); j -= min; } } @Override // o.InterfaceC15142giR public final long c(byte b) throws IOException { if (this.a) { throw new IllegalStateException("closed"); } do { long j = 0; if (0 < this.c.a) { do { long a = this.c.a(b, j); if (a != -1) { return a; } j = this.c.a; } while (this.b.read(this.c, 2048L) != -1); return -1L; } } while (this.b.read(this.c, 2048L) != -1); return -1L; } @Override // o.InterfaceC15142giR public final InputStream g() { return new InputStream(this) { // from class: o.gjh.5 private C15187gjh d; { this.d = this; } @Override // java.io.InputStream public final int read() throws IOException { if (this.d.a) { throw new IOException("closed"); } if (this.d.c.a == 0 && this.d.b.read(this.d.c, 2048L) == -1) { return -1; } return this.d.c.i() & UnsignedBytes.MAX_VALUE; } @Override // java.io.InputStream public final int read(byte[] bArr, int i, int i2) throws IOException { if (this.d.a) { throw new IOException("closed"); } C15183gjd.e(bArr.length, i, i2); if (this.d.c.a == 0 && this.d.b.read(this.d.c, 2048L) == -1) { return -1; } return this.d.c.b(bArr, i, i2); } @Override // java.io.InputStream public final int available() throws IOException { if (this.d.a) { throw new IOException("closed"); } return (int) Math.min(this.d.c.a, 2147483647L); } @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { this.d.close(); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.d); sb.append(".inputStream()"); return sb.toString(); } }; } @Override // o.giZ, java.io.Closeable, java.lang.AutoCloseable public final void close() throws IOException { if (this.a) { return; } this.a = true; this.b.close(); giM gim = this.c; try { gim.f(gim.a); } catch (EOFException e) { throw new AssertionError(e); } } @Override // o.giZ public final giY timeout() { return this.b.timeout(); } public final String toString() { StringBuilder sb = new StringBuilder("buffer("); sb.append(this.b); sb.append(")"); return sb.toString(); } @Override // o.InterfaceC15142giR public final boolean a() throws IOException { if (this.a) { throw new IllegalStateException("closed"); } return this.c.a == 0 && this.b.read(this.c, 2048L) == -1; } @Override // o.InterfaceC15142giR public final byte i() throws IOException { if (a(1L)) { return this.c.i(); } throw new EOFException(); } @Override // o.InterfaceC15142giR public final byte[] d(long j) throws IOException { if (a(j)) { return this.c.d(j); } throw new EOFException(); } @Override // o.InterfaceC15142giR public final giP e(long j) throws IOException { if (!a(j)) { throw new EOFException(); } return new giP(this.c.d(j)); } @Override // o.InterfaceC15142giR public final long f() throws IOException { byte b; if (a(1L)) { int i = 0; while (true) { int i2 = i + 1; if (!a(i2)) { break; } b = this.c.b(i); if ((b < 48 || b > 57) && !(i == 0 && b == 45)) { break; } i = i2; } if (i == 0) { throw new NumberFormatException(String.format("Expected leading [0-9] or '-' character but was %#x", Byte.valueOf(b))); } return this.c.f(); } throw new EOFException(); } /* JADX WARN: Code restructure failed: missing block: B:22:0x0033, code lost: if (r0 == 0) goto L22; */ /* JADX WARN: Code restructure failed: missing block: B:24:0x0049, code lost: throw new java.lang.NumberFormatException(java.lang.String.format("Expected leading [0-9a-fA-F] character but was %#x", java.lang.Byte.valueOf(r2))); */ @Override // o.InterfaceC15142giR /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long l() throws java.io.IOException { /* r5 = this; r0 = 1 boolean r0 = r5.a(r0) if (r0 == 0) goto L51 r0 = 0 L9: int r1 = r0 + 1 long r2 = (long) r1 boolean r2 = r5.a(r2) if (r2 == 0) goto L4a o.giM r2 = r5.c long r3 = (long) r0 byte r2 = r2.b(r3) r3 = 48 if (r2 < r3) goto L21 r3 = 57 if (r2 <= r3) goto L31 L21: r3 = 97 if (r2 < r3) goto L29 r3 = 102(0x66, float:1.43E-43) if (r2 <= r3) goto L31 L29: r3 = 65 if (r2 < r3) goto L33 r3 = 70 if (r2 > r3) goto L33 L31: r0 = r1 goto L9 L33: if (r0 == 0) goto L36 goto L4a L36: java.lang.Byte r0 = java.lang.Byte.valueOf(r2) java.lang.Object[] r0 = new java.lang.Object[]{r0} java.lang.NumberFormatException r1 = new java.lang.NumberFormatException java.lang.String r2 = "Expected leading [0-9a-fA-F] character but was %#x" java.lang.String r0 = java.lang.String.format(r2, r0) r1.(r0) throw r1 L4a: o.giM r0 = r5.c long r0 = r0.l() return r0 L51: java.io.EOFException r0 = new java.io.EOFException r0.() throw r0 */ throw new UnsupportedOperationException("Method not decompiled: o.C15187gjh.l():long"); } @Override // o.InterfaceC15142giR public final int k() throws IOException { if (a(4L)) { return this.c.k(); } throw new EOFException(); } @Override // o.InterfaceC15142giR public final int n() throws IOException { if (!a(4L)) { throw new EOFException(); } return C15183gjd.c(this.c.k()); } @Override // o.InterfaceC15142giR public final short o() throws IOException { if (a(2L)) { return this.c.o(); } throw new EOFException(); } @Override // o.InterfaceC15142giR public final short m() throws IOException { if (!a(2L)) { throw new EOFException(); } return C15183gjd.c(this.c.o()); } @Override // o.InterfaceC15142giR public final giM b() { return this.c; } }