2021-11-02 06:38:17 +00:00
|
|
|
package g0;
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.d.b.a.a;
|
2021-11-02 06:38:17 +00:00
|
|
|
import java.io.EOFException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.zip.DataFormatException;
|
|
|
|
import java.util.zip.Inflater;
|
|
|
|
/* compiled from: InflaterSource.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-11-02 06:38:17 +00:00
|
|
|
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");
|
2022-03-07 09:34:54 +00:00
|
|
|
int i = (j > 0L ? 1 : (j == 0L ? 0 : -1));
|
2021-11-02 06:38:17 +00:00
|
|
|
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) {
|
2022-03-07 09:34:54 +00:00
|
|
|
return 0L;
|
2021-11-02 06:38:17 +00:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
s N = eVar.N(1);
|
2022-03-07 09:34:54 +00:00
|
|
|
int min = (int) Math.min(j, 8192 - N.c);
|
|
|
|
if (this.m.needsInput() && !this.l.w()) {
|
|
|
|
s sVar = this.l.g().j;
|
|
|
|
if (sVar == null) {
|
|
|
|
d0.z.d.m.throwNpe();
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
int i2 = sVar.c;
|
2022-03-14 07:58:47 +00:00
|
|
|
int i3 = sVar.f3671b;
|
2022-03-07 09:34:54 +00:00
|
|
|
int i4 = i2 - i3;
|
|
|
|
this.j = i4;
|
|
|
|
this.m.setInput(sVar.a, i3, i4);
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
2021-12-17 21:59:34 +00:00
|
|
|
int inflate = this.m.inflate(N.a, N.c, 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;
|
2022-03-07 09:34:54 +00:00
|
|
|
this.l.skip(remaining);
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
|
|
|
if (inflate > 0) {
|
2021-12-17 21:59:34 +00:00
|
|
|
N.c += inflate;
|
2022-03-07 09:34:54 +00:00
|
|
|
long j2 = inflate;
|
2021-12-02 18:53:44 +00:00
|
|
|
eVar.k += j2;
|
2021-11-02 06:38:17 +00:00
|
|
|
return j2;
|
|
|
|
}
|
2022-03-14 07:58:47 +00:00
|
|
|
if (N.f3671b == N.c) {
|
2021-12-02 18:53:44 +00:00
|
|
|
eVar.j = N.a();
|
2021-11-02 06:38:17 +00:00
|
|
|
t.a(N);
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
return 0L;
|
2021-11-02 06:38:17 +00:00
|
|
|
} 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()) {
|
2022-03-07 09:34:54 +00:00
|
|
|
return -1L;
|
2021-11-02 06:38:17 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|