package o; import java.io.IOException; import java.io.InputStream; /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.goj, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15370goj extends InputStream { private InputStream a; private boolean b = true; private final gnK e; /* JADX INFO: Access modifiers changed from: package-private */ public C15370goj(gnK gnk) { this.e = gnk; } @Override // java.io.InputStream public final int read(byte[] bArr, int i, int i2) throws IOException { InterfaceC15313gnA interfaceC15313gnA; int i3 = 0; if (this.a == null) { if (!this.b || (interfaceC15313gnA = (InterfaceC15313gnA) this.e.e()) == null) { return -1; } this.b = false; this.a = interfaceC15313gnA.e(); } while (true) { int read = this.a.read(bArr, i + i3, i2 - i3); if (read >= 0) { i3 += read; if (i3 == i2) { return i3; } } else { InterfaceC15313gnA interfaceC15313gnA2 = (InterfaceC15313gnA) this.e.e(); if (interfaceC15313gnA2 == null) { this.a = null; if (i3 <= 0) { return -1; } return i3; } this.a = interfaceC15313gnA2.e(); } } } @Override // java.io.InputStream public final int read() throws IOException { InterfaceC15313gnA interfaceC15313gnA; if (this.a == null) { if (!this.b || (interfaceC15313gnA = (InterfaceC15313gnA) this.e.e()) == null) { return -1; } this.b = false; this.a = interfaceC15313gnA.e(); } while (true) { int read = this.a.read(); if (read >= 0) { return read; } InterfaceC15313gnA interfaceC15313gnA2 = (InterfaceC15313gnA) this.e.e(); if (interfaceC15313gnA2 == null) { this.a = null; return -1; } this.a = interfaceC15313gnA2.e(); } } }