111 lines
2.9 KiB
Java
111 lines
2.9 KiB
Java
package c.f.d.g;
|
|
|
|
import c.f.d.e.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.Objects;
|
|
/* compiled from: PooledByteArrayBufferedInputStream */
|
|
public class f extends InputStream {
|
|
public final InputStream i;
|
|
public final byte[] j;
|
|
public final c.f.d.h.f<byte[]> k;
|
|
public int l = 0;
|
|
public int m = 0;
|
|
public boolean n = false;
|
|
|
|
public f(InputStream inputStream, byte[] bArr, c.f.d.h.f<byte[]> fVar) {
|
|
Objects.requireNonNull(inputStream);
|
|
this.i = inputStream;
|
|
Objects.requireNonNull(bArr);
|
|
this.j = bArr;
|
|
Objects.requireNonNull(fVar);
|
|
this.k = fVar;
|
|
}
|
|
|
|
public final boolean a() throws IOException {
|
|
if (this.m < this.l) {
|
|
return true;
|
|
}
|
|
int read = this.i.read(this.j);
|
|
if (read <= 0) {
|
|
return false;
|
|
}
|
|
this.l = read;
|
|
this.m = 0;
|
|
return true;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int available() throws IOException {
|
|
AnimatableValueParser.B(this.m <= this.l);
|
|
b();
|
|
return this.i.available() + (this.l - this.m);
|
|
}
|
|
|
|
public final void b() throws IOException {
|
|
if (this.n) {
|
|
throw new IOException("stream already closed");
|
|
}
|
|
}
|
|
|
|
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
if (!this.n) {
|
|
this.n = true;
|
|
this.k.release(this.j);
|
|
super.close();
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public void finalize() throws Throwable {
|
|
if (!this.n) {
|
|
a.e("PooledByteInputStream", "Finalized without closing");
|
|
close();
|
|
}
|
|
super.finalize();
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read() throws IOException {
|
|
AnimatableValueParser.B(this.m <= this.l);
|
|
b();
|
|
if (!a()) {
|
|
return -1;
|
|
}
|
|
byte[] bArr = this.j;
|
|
int i = this.m;
|
|
this.m = i + 1;
|
|
return bArr[i] & 255;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public int read(byte[] bArr, int i, int i2) throws IOException {
|
|
AnimatableValueParser.B(this.m <= this.l);
|
|
b();
|
|
if (!a()) {
|
|
return -1;
|
|
}
|
|
int min = Math.min(this.l - this.m, i2);
|
|
System.arraycopy(this.j, this.m, bArr, i, min);
|
|
this.m += min;
|
|
return min;
|
|
}
|
|
|
|
@Override // java.io.InputStream
|
|
public long skip(long j) throws IOException {
|
|
AnimatableValueParser.B(this.m <= this.l);
|
|
b();
|
|
int i = this.l;
|
|
int i2 = this.m;
|
|
long j2 = (long) (i - i2);
|
|
if (j2 >= j) {
|
|
this.m = (int) (((long) i2) + j);
|
|
return j;
|
|
}
|
|
this.m = i;
|
|
return this.i.skip(j - j2) + j2;
|
|
}
|
|
}
|