discord-jadx/app/src/main/java/g0/m.java

112 lines
3.5 KiB
Java

package g0;
import c.d.b.a.a;
import java.io.EOFException;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
/* compiled from: InflaterSource.kt */
public final class m implements x {
public int i;
public boolean j;
public final g k;
public final Inflater l;
public m(g gVar, Inflater inflater) {
d0.z.d.m.checkParameterIsNotNull(gVar, "source");
d0.z.d.m.checkParameterIsNotNull(inflater, "inflater");
this.k = gVar;
this.l = inflater;
}
public m(x xVar, Inflater inflater) {
d0.z.d.m.checkParameterIsNotNull(xVar, "source");
d0.z.d.m.checkParameterIsNotNull(inflater, "inflater");
d0.z.d.m.checkParameterIsNotNull(xVar, "$this$buffer");
r rVar = new r(xVar);
d0.z.d.m.checkParameterIsNotNull(rVar, "source");
d0.z.d.m.checkParameterIsNotNull(inflater, "inflater");
this.k = rVar;
this.l = inflater;
}
public final long a(e eVar, long j) throws IOException {
d0.z.d.m.checkParameterIsNotNull(eVar, "sink");
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
if (!(i >= 0)) {
throw new IllegalArgumentException(a.p("byteCount < 0: ", j).toString());
} else if (!(!this.j)) {
throw new IllegalStateException("closed".toString());
} else if (i == 0) {
return 0;
} else {
try {
s N = eVar.N(1);
int min = (int) Math.min(j, (long) (8192 - N.f2787c));
if (this.l.needsInput()) {
if (!this.k.v()) {
s sVar = this.k.g().i;
if (sVar == null) {
d0.z.d.m.throwNpe();
}
int i2 = sVar.f2787c;
int i3 = sVar.b;
int i4 = i2 - i3;
this.i = i4;
this.l.setInput(sVar.a, i3, i4);
}
}
int inflate = this.l.inflate(N.a, N.f2787c, min);
int i5 = this.i;
if (i5 != 0) {
int remaining = i5 - this.l.getRemaining();
this.i -= remaining;
this.k.skip((long) remaining);
}
if (inflate > 0) {
N.f2787c += inflate;
long j2 = (long) inflate;
eVar.j += j2;
return j2;
}
if (N.b == N.f2787c) {
eVar.i = N.a();
t.a(N);
}
return 0;
} catch (DataFormatException e) {
throw new IOException(e);
}
}
}
@Override // g0.x, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (!this.j) {
this.l.end();
this.j = true;
this.k.close();
}
}
@Override // g0.x
public long h0(e eVar, long j) throws IOException {
d0.z.d.m.checkParameterIsNotNull(eVar, "sink");
do {
long a = a(eVar, j);
if (a > 0) {
return a;
}
if (this.l.finished() || this.l.needsDictionary()) {
return -1;
}
} while (!this.k.v());
throw new EOFException("source exhausted prematurely");
}
@Override // g0.x
public y timeout() {
return this.k.timeout();
}
}