63 lines
1.7 KiB
Java
63 lines
1.7 KiB
Java
|
package o;
|
||
|
|
||
|
import java.io.FilterInputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class FTt extends FilterInputStream {
|
||
|
private int a;
|
||
|
private final long b;
|
||
|
|
||
|
public FTt(InputStream inputStream, long j) {
|
||
|
super(inputStream);
|
||
|
this.b = j;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int available() throws IOException {
|
||
|
int max;
|
||
|
synchronized (this) {
|
||
|
max = (int) Math.max(this.b - this.a, ((FilterInputStream) this).in.available());
|
||
|
}
|
||
|
return max;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int read() throws IOException {
|
||
|
int read;
|
||
|
synchronized (this) {
|
||
|
read = super.read();
|
||
|
c(read >= 0 ? 1 : -1);
|
||
|
}
|
||
|
return read;
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int read(byte[] bArr) throws IOException {
|
||
|
return read(bArr, 0, bArr.length);
|
||
|
}
|
||
|
|
||
|
@Override // java.io.FilterInputStream, java.io.InputStream
|
||
|
public final int read(byte[] bArr, int i, int i2) throws IOException {
|
||
|
int c;
|
||
|
synchronized (this) {
|
||
|
c = c(super.read(bArr, i, i2));
|
||
|
}
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
private int c(int i) throws IOException {
|
||
|
if (i >= 0) {
|
||
|
this.a += i;
|
||
|
} else if (this.b - this.a > 0) {
|
||
|
StringBuilder sb = new StringBuilder("Failed to read all expected data, expected: ");
|
||
|
sb.append(this.b);
|
||
|
sb.append(", but read: ");
|
||
|
sb.append(this.a);
|
||
|
throw new IOException(sb.toString());
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
}
|