what-the-bank/sources/o/shM.java

96 lines
2.3 KiB
Java

package o;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class shM extends Eaa {
public long c = 0;
private final InputStream d;
public shM(InputStream inputStream) {
this.d = inputStream;
}
@Override // o.Eaa
public final byte b() throws IOException {
int read = this.d.read();
if (read == -1) {
throw new EOFException("End of data reached.");
}
this.c++;
return (byte) read;
}
@Override // o.Eaa
public final byte[] a(int i) throws IOException {
try {
byte[] bArr = new byte[i];
c(bArr, 0, i);
return bArr;
} catch (OutOfMemoryError unused) {
throw new EOFException("End of data reached.");
}
}
@Override // o.Eaa
public final void c(byte[] bArr, int i, int i2) throws IOException {
int i3 = 0;
while (i3 != i2) {
int read = this.d.read(bArr, i + i3, i2 - i3);
if (read == -1) {
throw new EOFException("End of data reached.");
}
i3 += read;
}
this.c += i3;
}
@Override // o.Eaa
public final void b(long j) throws IOException {
if (j < 0) {
throw new IllegalArgumentException("n must be zero or greater.");
}
long c = c(j);
if (c != j) {
throw new EOFException(String.format("Unable to skip. Requested %d bytes but only %d remained.", Long.valueOf(j), Long.valueOf(c)));
}
}
@Override // o.Eaa
public final boolean d(long j) throws IOException {
if (j >= 0) {
return c(j) == j;
}
throw new IllegalArgumentException("n must be zero or greater.");
}
@Override // o.Eaa
public final int d() {
try {
return this.d.available();
} catch (IOException unused) {
return 0;
}
}
private long c(long j) throws IOException {
long j2 = 0;
while (j2 != j) {
long skip = this.d.skip(j - j2);
j2 += skip;
if (skip == 0) {
break;
}
}
this.c += j2;
return j2;
}
@Override // o.Eaa
public final long c() {
return this.c;
}
}