package o; import com.google.common.primitives.UnsignedBytes; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.charset.Charset; /* renamed from: o.giz, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C15171giz implements InterfaceC15149gid { public final giD b; public final C15111ghZ c; public boolean d; public C15171giz(giD gid) { C14957gcv.e(gid, ""); this.b = gid; this.c = new C15111ghZ(); } @Override // o.InterfaceC15149gid public final String d(Charset charset) { C14957gcv.e(charset, ""); this.c.c(this.b); C15111ghZ c15111ghZ = this.c; C14957gcv.e(charset, ""); return c15111ghZ.b(c15111ghZ.c, charset); } @Override // o.InterfaceC15149gid public final String t() { return b(Long.MAX_VALUE); } @Override // o.InterfaceC15149gid public final long a(C15155gij c15155gij) { C14957gcv.e(c15155gij, ""); C14957gcv.e(c15155gij, ""); if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } long j = 0; while (true) { long a = this.c.a(c15155gij, j); if (a != -1) { return a; } long j2 = this.c.c; if (this.b.read(this.c, 8192L) == -1) { return -1L; } j = Math.max(j, (j2 - c15155gij.a()) + 1); } } @Override // o.InterfaceC15149gid public final long e(C15155gij c15155gij) { C14957gcv.e(c15155gij, ""); C14957gcv.e(c15155gij, ""); if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } long j = 0; while (true) { long c = this.c.c(c15155gij, j); if (c != -1) { return c; } long j2 = this.c.c; if (this.b.read(this.c, 8192L) == -1) { return -1L; } j = Math.max(j, j2); } } /* renamed from: o.giz$IeS */ /* loaded from: classes.dex */ public static final class IeS extends InputStream { private C15171giz c; IeS(C15171giz c15171giz) { this.c = c15171giz; } @Override // java.io.InputStream public final int read() { if (this.c.d) { throw new IOException("closed"); } if (this.c.c.c == 0 && this.c.b.read(this.c.c, 8192L) == -1) { return -1; } return this.c.c.f() & UnsignedBytes.MAX_VALUE; } @Override // java.io.InputStream public final int read(byte[] bArr, int i, int i2) { C14957gcv.e(bArr, ""); if (this.c.d) { throw new IOException("closed"); } giE.d(bArr.length, i, i2); if (this.c.c.c == 0 && this.c.b.read(this.c.c, 8192L) == -1) { return -1; } return this.c.c.c(bArr, i, i2); } @Override // java.io.InputStream public final int available() { if (this.c.d) { throw new IOException("closed"); } return (int) Math.min(this.c.c.c, 2147483647L); } @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable public final void close() { this.c.close(); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.c); sb.append(".inputStream()"); return sb.toString(); } } @Override // o.InterfaceC15149gid public final InputStream h() { return new IeS(this); } @Override // o.InterfaceC15149gid public final void g(long j) { if (!a(j)) { throw new EOFException(); } } @Override // o.InterfaceC15149gid public final C15155gij l() { this.c.c(this.b); C15111ghZ c15111ghZ = this.c; return c15111ghZ.c(c15111ghZ.c); } @Override // o.InterfaceC15149gid public final int c(C15163gir c15163gir) { C14957gcv.e(c15163gir, ""); if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } while (true) { int a = giJ.a(this.c, c15163gir, true); if (a != -2) { if (a != -1) { this.c.j(c15163gir.d[a].a()); return a; } } else if (this.b.read(this.c, 8192L) == -1) { break; } } return -1; } @Override // o.InterfaceC15149gid public final byte[] k() { this.c.c(this.b); C15111ghZ c15111ghZ = this.c; return c15111ghZ.e(c15111ghZ.c); } @Override // o.InterfaceC15149gid public final void d(byte[] bArr) { C14957gcv.e(bArr, ""); try { if (a(bArr.length)) { this.c.d(bArr); return; } throw new EOFException(); } catch (EOFException e) { int i = 0; while (this.c.c > 0) { C15111ghZ c15111ghZ = this.c; int c = c15111ghZ.c(bArr, i, (int) c15111ghZ.c); if (c == -1) { throw new AssertionError(); } i += c; } throw e; } } @Override // o.InterfaceC15149gid public final long d(InterfaceC15168giw interfaceC15168giw) { C14957gcv.e(interfaceC15168giw, ""); long j = 0; while (this.b.read(this.c, 8192L) != -1) { long e = this.c.e(); if (e > 0) { j += e; interfaceC15168giw.write(this.c, e); } } if (this.c.c <= 0) { return j; } long j2 = j + this.c.c; C15111ghZ c15111ghZ = this.c; interfaceC15168giw.write(c15111ghZ, c15111ghZ.c); return j2; } @Override // o.InterfaceC15149gid public final String b(long j) { if (j < 0) { throw new IllegalArgumentException("limit < 0: ".concat(String.valueOf(j)).toString()); } long j2 = j == Long.MAX_VALUE ? Long.MAX_VALUE : j + 1; long b = b((byte) 10, 0L, j2); if (b != -1) { return giJ.d(this.c, b); } if (j2 < Long.MAX_VALUE && a(j2) && this.c.d(j2 - 1) == 13 && a(1 + j2) && this.c.d(j2) == 10) { return giJ.d(this.c, j2); } C15111ghZ c15111ghZ = new C15111ghZ(); C15111ghZ c15111ghZ2 = this.c; c15111ghZ2.c(c15111ghZ, 0L, Math.min(32L, c15111ghZ2.c)); StringBuilder sb = new StringBuilder("\\n not found: limit="); sb.append(Math.min(this.c.c, j)); sb.append(" content="); sb.append(c15111ghZ.c(c15111ghZ.c).c()); sb.append((char) 8230); throw new EOFException(sb.toString()); } public final long b(byte b, long j, long j2) { if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } if (0 > j2) { throw new IllegalArgumentException("fromIndex=0 toIndex=".concat(String.valueOf(j2)).toString()); } while (j < j2) { long a = this.c.a(b, j, j2); if (a != -1) { return a; } long j3 = this.c.c; if (j3 >= j2 || this.b.read(this.c, 8192L) == -1) { return -1L; } j = Math.max(j, j3); } return -1L; } @Override // o.InterfaceC15149gid public final InterfaceC15149gid g() { return C15160gio.c(new C15161gip(this)); } @Override // o.giD, java.io.Closeable, java.lang.AutoCloseable public final void close() { if (this.d) { return; } this.d = true; this.b.close(); C15111ghZ c15111ghZ = this.c; c15111ghZ.j(c15111ghZ.c); } @Override // o.giD public final C15139giB 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.InterfaceC15149gid public final boolean j() { if (!this.d) { return this.c.c == 0 && this.b.read(this.c, 8192L) == -1; } throw new IllegalStateException("closed".toString()); } @Override // o.InterfaceC15149gid public final boolean e(long j, C15155gij c15155gij) { int i; C14957gcv.e(c15155gij, ""); int a = c15155gij.a(); C14957gcv.e(c15155gij, ""); if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } if (j >= 0 && a >= 0 && c15155gij.a() >= a) { for (0; i < a; i + 1) { long j2 = i + j; i = (a(1 + j2) && this.c.d(j2) == c15155gij.c(i)) ? i + 1 : 0; } return true; } return false; } @Override // java.nio.channels.ReadableByteChannel public final int read(ByteBuffer byteBuffer) { C14957gcv.e(byteBuffer, ""); if (this.c.c == 0 && this.b.read(this.c, 8192L) == -1) { return -1; } return this.c.read(byteBuffer); } @Override // o.giD public final long read(C15111ghZ c15111ghZ, long j) { C14957gcv.e(c15111ghZ, ""); if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)).toString()); } if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } if (this.c.c == 0 && this.b.read(this.c, 8192L) == -1) { return -1L; } return this.c.read(c15111ghZ, Math.min(j, this.c.c)); } @Override // o.InterfaceC15149gid public final byte f() { if (a(1L)) { return this.c.f(); } throw new EOFException(); } @Override // o.InterfaceC15149gid public final byte[] e(long j) { if (a(j)) { return this.c.e(j); } throw new EOFException(); } @Override // o.InterfaceC15149gid public final C15155gij c(long j) { if (a(j)) { return this.c.c(j); } throw new EOFException(); } /* JADX WARN: Code restructure failed: missing block: B:17:0x002b, code lost: if (r4 == 0) goto L18; */ /* JADX WARN: Code restructure failed: missing block: B:18:0x002e, code lost: r0 = new java.lang.StringBuilder("Expected a digit or '-' but was 0x"); r1 = java.lang.Integer.toString(r8, o.gdN.b(o.gdN.b(16))); o.C14957gcv.c((java.lang.Object) r1, ""); r0.append(r1); */ /* JADX WARN: Code restructure failed: missing block: B:19:0x0054, code lost: throw new java.lang.NumberFormatException(r0.toString()); */ @Override // o.InterfaceC15149gid /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long o() { /* r10 = this; r0 = 1 boolean r2 = r10.a(r0) if (r2 == 0) goto L5c r2 = 0 r4 = r2 Lb: long r6 = r4 + r0 boolean r8 = r10.a(r6) if (r8 == 0) goto L55 o.ghZ r8 = r10.c byte r8 = r8.d(r4) r9 = 48 if (r8 < r9) goto L21 r9 = 57 if (r8 <= r9) goto L29 L21: int r4 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1)) if (r4 != 0) goto L2b r5 = 45 if (r8 != r5) goto L2b L29: r4 = r6 goto Lb L2b: if (r4 == 0) goto L2e goto L55 L2e: java.lang.StringBuilder r0 = new java.lang.StringBuilder java.lang.String r1 = "Expected a digit or '-' but was 0x" r0.(r1) r1 = 16 int r1 = o.gdN.b(r1) int r1 = o.gdN.b(r1) java.lang.String r1 = java.lang.Integer.toString(r8, r1) java.lang.String r2 = "" o.C14957gcv.c(r1, r2) java.lang.NumberFormatException r2 = new java.lang.NumberFormatException r0.append(r1) java.lang.String r0 = r0.toString() r2.(r0) throw r2 L55: o.ghZ r0 = r10.c long r0 = r0.o() return r0 L5c: java.io.EOFException r0 = new java.io.EOFException r0.() throw r0 */ throw new UnsupportedOperationException("Method not decompiled: o.C15171giz.o():long"); } @Override // o.InterfaceC15149gid public final void e(C15111ghZ c15111ghZ, long j) { C14957gcv.e(c15111ghZ, ""); try { if (a(j)) { this.c.e(c15111ghZ, j); return; } throw new EOFException(); } catch (EOFException e) { c15111ghZ.c((giD) this.c); throw e; } } /* 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:23:0x0036, code lost: r0 = new java.lang.StringBuilder("Expected leading [0-9a-fA-F] character but was 0x"); r1 = java.lang.Integer.toString(r2, o.gdN.b(o.gdN.b(16))); o.C14957gcv.c((java.lang.Object) r1, ""); r0.append(r1); */ /* JADX WARN: Code restructure failed: missing block: B:24:0x005c, code lost: throw new java.lang.NumberFormatException(r0.toString()); */ @Override // o.InterfaceC15149gid /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public final long m() { /* r5 = this; r0 = 1 boolean r0 = r5.a(r0) if (r0 == 0) goto L64 r0 = 0 L9: int r1 = r0 + 1 long r2 = (long) r1 boolean r2 = r5.a(r2) if (r2 == 0) goto L5d o.ghZ r2 = r5.c long r3 = (long) r0 byte r2 = r2.d(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 L5d L36: java.lang.StringBuilder r0 = new java.lang.StringBuilder java.lang.String r1 = "Expected leading [0-9a-fA-F] character but was 0x" r0.(r1) r1 = 16 int r1 = o.gdN.b(r1) int r1 = o.gdN.b(r1) java.lang.String r1 = java.lang.Integer.toString(r2, r1) java.lang.String r2 = "" o.C14957gcv.c(r1, r2) java.lang.NumberFormatException r2 = new java.lang.NumberFormatException r0.append(r1) java.lang.String r0 = r0.toString() r2.(r0) throw r2 L5d: o.ghZ r0 = r5.c long r0 = r0.m() return r0 L64: java.io.EOFException r0 = new java.io.EOFException r0.() throw r0 */ throw new UnsupportedOperationException("Method not decompiled: o.C15171giz.m():long"); } @Override // o.InterfaceC15149gid public final int n() { if (a(4L)) { return this.c.n(); } throw new EOFException(); } @Override // o.InterfaceC15149gid public final long p() { if (a(8L)) { return this.c.p(); } throw new EOFException(); } @Override // o.InterfaceC15149gid public final short s() { if (a(2L)) { return this.c.s(); } throw new EOFException(); } @Override // o.InterfaceC15149gid public final boolean a(long j) { if (j < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)).toString()); } if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } while (this.c.c < j) { if (this.b.read(this.c, 8192L) == -1) { return false; } } return true; } @Override // o.InterfaceC15149gid public final void j(long j) { if (!(!this.d)) { throw new IllegalStateException("closed".toString()); } while (j > 0) { if (this.c.c == 0 && this.b.read(this.c, 8192L) == -1) { throw new EOFException(); } long min = Math.min(j, this.c.c); this.c.j(min); j -= min; } } @Override // java.nio.channels.Channel public final boolean isOpen() { return !this.d; } @Override // o.InterfaceC15149gid, o.InterfaceC15148gic public final C15111ghZ i() { return this.c; } @Override // o.InterfaceC15149gid public final C15111ghZ c() { return this.c; } }