2021-11-02 06:38:17 +00:00
|
|
|
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 {
|
2021-12-02 18:53:44 +00:00
|
|
|
public int j;
|
|
|
|
public boolean k;
|
|
|
|
public final g l;
|
|
|
|
public final Inflater m;
|
2021-11-02 06:38:17 +00:00
|
|
|
|
|
|
|
public m(g gVar, Inflater inflater) {
|
|
|
|
d0.z.d.m.checkParameterIsNotNull(gVar, "source");
|
|
|
|
d0.z.d.m.checkParameterIsNotNull(inflater, "inflater");
|
2021-12-02 18:53:44 +00:00
|
|
|
this.l = gVar;
|
|
|
|
this.m = inflater;
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2021-12-02 18:53:44 +00:00
|
|
|
this.l = rVar;
|
|
|
|
this.m = inflater;
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)) {
|
2021-11-05 06:48:17 +00:00
|
|
|
throw new IllegalArgumentException(a.s("byteCount < 0: ", j).toString());
|
2021-12-02 18:53:44 +00:00
|
|
|
} else if (!(!this.k)) {
|
2021-11-02 06:38:17 +00:00
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
} else if (i == 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
s N = eVar.N(1);
|
2021-12-03 20:28:00 +00:00
|
|
|
int min = (int) Math.min(j, (long) (8192 - N.f2945c));
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.m.needsInput()) {
|
|
|
|
if (!this.l.w()) {
|
|
|
|
s sVar = this.l.g().j;
|
2021-11-02 06:38:17 +00:00
|
|
|
if (sVar == null) {
|
|
|
|
d0.z.d.m.throwNpe();
|
|
|
|
}
|
2021-12-03 20:28:00 +00:00
|
|
|
int i2 = sVar.f2945c;
|
2021-11-02 06:38:17 +00:00
|
|
|
int i3 = sVar.b;
|
|
|
|
int i4 = i2 - i3;
|
2021-12-02 18:53:44 +00:00
|
|
|
this.j = i4;
|
|
|
|
this.m.setInput(sVar.a, i3, i4);
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-03 20:28:00 +00:00
|
|
|
int inflate = this.m.inflate(N.a, N.f2945c, min);
|
2021-12-02 18:53:44 +00:00
|
|
|
int i5 = this.j;
|
2021-11-02 06:38:17 +00:00
|
|
|
if (i5 != 0) {
|
2021-12-02 18:53:44 +00:00
|
|
|
int remaining = i5 - this.m.getRemaining();
|
|
|
|
this.j -= remaining;
|
|
|
|
this.l.skip((long) remaining);
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
if (inflate > 0) {
|
2021-12-03 20:28:00 +00:00
|
|
|
N.f2945c += inflate;
|
2021-11-02 06:38:17 +00:00
|
|
|
long j2 = (long) inflate;
|
2021-12-02 18:53:44 +00:00
|
|
|
eVar.k += j2;
|
2021-11-02 06:38:17 +00:00
|
|
|
return j2;
|
|
|
|
}
|
2021-12-03 20:28:00 +00:00
|
|
|
if (N.b == N.f2945c) {
|
2021-12-02 18:53:44 +00:00
|
|
|
eVar.j = N.a();
|
2021-11-02 06:38:17 +00:00
|
|
|
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 {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.m.end();
|
|
|
|
this.k = true;
|
|
|
|
this.l.close();
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.x
|
2021-11-05 06:48:17 +00:00
|
|
|
public long i0(e eVar, long j) throws IOException {
|
2021-11-02 06:38:17 +00:00
|
|
|
d0.z.d.m.checkParameterIsNotNull(eVar, "sink");
|
|
|
|
do {
|
|
|
|
long a = a(eVar, j);
|
|
|
|
if (a > 0) {
|
|
|
|
return a;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.m.finished() || this.m.needsDictionary()) {
|
2021-11-02 06:38:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
} while (!this.l.w());
|
2021-11-02 06:38:17 +00:00
|
|
|
throw new EOFException("source exhausted prematurely");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.x
|
|
|
|
public y timeout() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.l.timeout();
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
}
|