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

285 lines
9.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import com.google.common.primitives.UnsignedBytes;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* renamed from: o.ljW, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C16158ljW extends FilterInputStream {
private int a;
private int b;
public volatile byte[] c;
private final Opg d;
public int e;
private int g;
@Override // java.io.FilterInputStream, java.io.InputStream
public final boolean markSupported() {
return true;
}
public C16158ljW(InputStream inputStream, Opg opg) {
this(inputStream, opg, (byte) 0);
}
private C16158ljW(InputStream inputStream, Opg opg, byte b) {
super(inputStream);
this.b = -1;
this.d = opg;
this.c = (byte[]) opg.e(65536, byte[].class);
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final int available() throws IOException {
int i;
int i2;
int available;
synchronized (this) {
InputStream inputStream = ((FilterInputStream) this).in;
if (this.c != null && inputStream != null) {
i = this.a;
i2 = this.g;
available = inputStream.available();
} else {
throw new IOException("BufferedInputStream is closed");
}
}
return (i - i2) + available;
}
public final void a() {
synchronized (this) {
if (this.c != null) {
this.d.b(this.c);
this.c = null;
}
}
}
@Override // java.io.FilterInputStream, java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public final void close() throws IOException {
if (this.c != null) {
this.d.b(this.c);
this.c = null;
}
InputStream inputStream = ((FilterInputStream) this).in;
((FilterInputStream) this).in = null;
if (inputStream != null) {
inputStream.close();
}
}
private int b(InputStream inputStream, byte[] bArr) throws IOException {
int i = this.b;
if (i != -1) {
int i2 = this.g;
int i3 = this.e;
if (i2 - i < i3) {
if (i == 0 && i3 > bArr.length && this.a == bArr.length) {
int length = bArr.length << 1;
if (length <= i3) {
i3 = length;
}
byte[] bArr2 = (byte[]) this.d.e(i3, byte[].class);
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
this.c = bArr2;
this.d.b(bArr);
bArr = bArr2;
} else if (i > 0) {
System.arraycopy(bArr, i, bArr, 0, bArr.length - i);
}
int i4 = this.g - this.b;
this.g = i4;
this.b = 0;
this.a = 0;
int read = inputStream.read(bArr, i4, bArr.length - i4);
int i5 = this.g;
if (read > 0) {
i5 += read;
}
this.a = i5;
return read;
}
}
int read2 = inputStream.read(bArr);
if (read2 > 0) {
this.b = -1;
this.g = 0;
this.a = read2;
}
return read2;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final void mark(int i) {
synchronized (this) {
this.e = Math.max(this.e, i);
this.b = this.g;
}
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final int read() throws IOException {
synchronized (this) {
byte[] bArr = this.c;
InputStream inputStream = ((FilterInputStream) this).in;
if (bArr != null && inputStream != null) {
if (this.g >= this.a && b(inputStream, bArr) == -1) {
return -1;
}
if (bArr != this.c && (bArr = this.c) == null) {
throw new IOException("BufferedInputStream is closed");
}
int i = this.a;
int i2 = this.g;
if (i - i2 <= 0) {
return -1;
}
this.g = i2 + 1;
return bArr[i2] & UnsignedBytes.MAX_VALUE;
}
throw new IOException("BufferedInputStream is closed");
}
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final int read(byte[] bArr, int i, int i2) throws IOException {
int i3;
int i4;
synchronized (this) {
byte[] bArr2 = this.c;
if (bArr2 == null) {
throw new IOException("BufferedInputStream is closed");
}
if (i2 == 0) {
return 0;
}
InputStream inputStream = ((FilterInputStream) this).in;
if (inputStream == null) {
throw new IOException("BufferedInputStream is closed");
}
int i5 = this.g;
int i6 = this.a;
if (i5 < i6) {
int i7 = i6 - i5;
if (i7 >= i2) {
i7 = i2;
}
System.arraycopy(bArr2, i5, bArr, i, i7);
this.g += i7;
if (i7 == i2 || inputStream.available() == 0) {
return i7;
}
i += i7;
i3 = i2 - i7;
} else {
i3 = i2;
}
while (true) {
if (this.b == -1 && i3 >= bArr2.length) {
i4 = inputStream.read(bArr, i, i3);
if (i4 == -1) {
return i3 != i2 ? i2 - i3 : -1;
}
} else {
if (b(inputStream, bArr2) == -1) {
return i3 != i2 ? i2 - i3 : -1;
}
if (bArr2 != this.c && (bArr2 = this.c) == null) {
throw new IOException("BufferedInputStream is closed");
}
int i8 = this.a;
int i9 = this.g;
i4 = i8 - i9;
if (i4 >= i3) {
i4 = i3;
}
System.arraycopy(bArr2, i9, bArr, i, i4);
this.g += i4;
}
i3 -= i4;
if (i3 == 0) {
return i2;
}
if (inputStream.available() == 0) {
return i2 - i3;
}
i += i4;
}
}
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final void reset() throws IOException {
synchronized (this) {
if (this.c == null) {
throw new IOException("Stream is closed");
}
int i = this.b;
if (-1 == i) {
StringBuilder sb = new StringBuilder("Mark has been invalidated, pos: ");
sb.append(this.g);
sb.append(" markLimit: ");
sb.append(this.e);
throw new RVV(sb.toString());
}
this.g = i;
}
}
@Override // java.io.FilterInputStream, java.io.InputStream
public final long skip(long j) throws IOException {
synchronized (this) {
if (j < 1) {
return 0L;
}
byte[] bArr = this.c;
if (bArr != null) {
InputStream inputStream = ((FilterInputStream) this).in;
if (inputStream == null) {
throw new IOException("BufferedInputStream is closed");
}
int i = this.a;
int i2 = this.g;
if (i - i2 >= j) {
this.g = (int) (i2 + j);
return j;
}
long j2 = i - i2;
this.g = i;
if (this.b != -1 && j <= this.e) {
if (b(inputStream, bArr) == -1) {
return j2;
}
int i3 = this.a;
int i4 = this.g;
if (i3 - i4 >= j - j2) {
this.g = (int) ((i4 + j) - j2);
return j;
}
long j3 = i3;
long j4 = i4;
this.g = i3;
return (j2 + j3) - j4;
}
long skip = inputStream.skip(j - j2);
if (skip > 0) {
this.b = -1;
}
return j2 + skip;
}
throw new IOException("BufferedInputStream is closed");
}
}
/* renamed from: o.ljW$RVV */
/* loaded from: classes.dex */
static class RVV extends IOException {
public RVV(String str) {
super(str);
}
}
}