discord-jadx/app/src/main/java/c/i/a/c/a2/e.java

203 lines
5.0 KiB
Java

package c.i.a.c.a2;
import c.i.a.c.h2.f;
import c.i.a.c.i2.f0;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.Arrays;
/* compiled from: DefaultExtractorInput */
public final class e implements i {
public final byte[] a = new byte[4096];
public final f b;
/* renamed from: c reason: collision with root package name */
public final long f656c;
public long d;
public byte[] e = new byte[65536];
public int f;
public int g;
public e(f fVar, long j, long j2) {
this.b = fVar;
this.d = j;
this.f656c = j2;
}
@Override // c.i.a.c.a2.i
public long b() {
return this.f656c;
}
@Override // c.i.a.c.a2.i
public boolean c(byte[] bArr, int i, int i2, boolean z2) throws IOException {
int i3;
int i4 = this.g;
if (i4 == 0) {
i3 = 0;
} else {
i3 = Math.min(i4, i2);
System.arraycopy(this.e, 0, bArr, i, i3);
s(i3);
}
int i5 = i3;
while (i5 < i2 && i5 != -1) {
i5 = r(bArr, i, i2, i5, z2);
}
p(i5);
return i5 != -1;
}
@Override // c.i.a.c.a2.i
public boolean e(byte[] bArr, int i, int i2, boolean z2) throws IOException {
if (!o(i2, z2)) {
return false;
}
System.arraycopy(this.e, this.f - i2, bArr, i, i2);
return true;
}
@Override // c.i.a.c.a2.i
public long f() {
return this.d + ((long) this.f);
}
@Override // c.i.a.c.a2.i
public void g(int i) throws IOException {
o(i, false);
}
@Override // c.i.a.c.a2.i
public long getPosition() {
return this.d;
}
@Override // c.i.a.c.a2.i
public int h(int i) throws IOException {
int min = Math.min(this.g, i);
s(min);
if (min == 0) {
byte[] bArr = this.a;
min = r(bArr, 0, Math.min(i, bArr.length), 0, true);
}
p(min);
return min;
}
@Override // c.i.a.c.a2.i
public int i(byte[] bArr, int i, int i2) throws IOException {
int i3;
q(i2);
int i4 = this.g;
int i5 = this.f;
int i6 = i4 - i5;
if (i6 == 0) {
i3 = r(this.e, i5, i2, 0, true);
if (i3 == -1) {
return -1;
}
this.g += i3;
} else {
i3 = Math.min(i2, i6);
}
System.arraycopy(this.e, this.f, bArr, i, i3);
this.f += i3;
return i3;
}
@Override // c.i.a.c.a2.i
public void k() {
this.f = 0;
}
@Override // c.i.a.c.a2.i
public void l(int i) throws IOException {
int min = Math.min(this.g, i);
s(min);
int i2 = min;
while (i2 < i && i2 != -1) {
i2 = r(this.a, -i2, Math.min(i, this.a.length + i2), i2, false);
}
p(i2);
}
@Override // c.i.a.c.a2.i
public void n(byte[] bArr, int i, int i2) throws IOException {
e(bArr, i, i2, false);
}
public boolean o(int i, boolean z2) throws IOException {
q(i);
int i2 = this.g - this.f;
while (i2 < i) {
i2 = r(this.e, this.f, i, i2, z2);
if (i2 == -1) {
return false;
}
this.g = this.f + i2;
}
this.f += i;
return true;
}
public final void p(int i) {
if (i != -1) {
this.d += (long) i;
}
}
public final void q(int i) {
int i2 = this.f + i;
byte[] bArr = this.e;
if (i2 > bArr.length) {
this.e = Arrays.copyOf(this.e, f0.h(bArr.length * 2, 65536 + i2, i2 + 524288));
}
}
public final int r(byte[] bArr, int i, int i2, int i3, boolean z2) throws IOException {
if (!Thread.interrupted()) {
int read = this.b.read(bArr, i + i3, i2 - i3);
if (read != -1) {
return i3 + read;
}
if (i3 == 0 && z2) {
return -1;
}
throw new EOFException();
}
throw new InterruptedIOException();
}
@Override // c.i.a.c.a2.i, c.i.a.c.h2.f
public int read(byte[] bArr, int i, int i2) throws IOException {
int i3 = this.g;
int i4 = 0;
if (i3 != 0) {
int min = Math.min(i3, i2);
System.arraycopy(this.e, 0, bArr, i, min);
s(min);
i4 = min;
}
if (i4 == 0) {
i4 = r(bArr, i, i2, 0, true);
}
p(i4);
return i4;
}
@Override // c.i.a.c.a2.i
public void readFully(byte[] bArr, int i, int i2) throws IOException {
c(bArr, i, i2, false);
}
public final void s(int i) {
int i2 = this.g - i;
this.g = i2;
this.f = 0;
byte[] bArr = this.e;
byte[] bArr2 = i2 < bArr.length - 524288 ? new byte[(65536 + i2)] : bArr;
System.arraycopy(bArr, i, bArr2, 0, i2);
this.e = bArr2;
}
}