2021-08-03 07:33:18 +00:00
|
|
|
package f0;
|
|
|
|
|
2021-10-15 06:18:26 +00:00
|
|
|
import c.d.b.a.a;
|
|
|
|
import c0.z.d.m;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.zip.Deflater;
|
|
|
|
import okio.BufferedSink;
|
|
|
|
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
|
|
|
|
/* compiled from: DeflaterSink.kt */
|
|
|
|
public final class h implements v {
|
|
|
|
public boolean i;
|
|
|
|
public final BufferedSink j;
|
|
|
|
public final Deflater k;
|
|
|
|
|
|
|
|
public h(v vVar, Deflater deflater) {
|
|
|
|
m.checkParameterIsNotNull(vVar, "sink");
|
|
|
|
m.checkParameterIsNotNull(deflater, "deflater");
|
|
|
|
m.checkParameterIsNotNull(vVar, "$this$buffer");
|
|
|
|
q qVar = new q(vVar);
|
|
|
|
m.checkParameterIsNotNull(qVar, "sink");
|
|
|
|
m.checkParameterIsNotNull(deflater, "deflater");
|
|
|
|
this.j = qVar;
|
|
|
|
this.k = deflater;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 06:18:26 +00:00
|
|
|
@IgnoreJRERequirement
|
|
|
|
public final void a(boolean z2) {
|
|
|
|
s N;
|
|
|
|
int i;
|
|
|
|
e g = this.j.g();
|
|
|
|
while (true) {
|
|
|
|
N = g.N(1);
|
|
|
|
if (z2) {
|
|
|
|
Deflater deflater = this.k;
|
|
|
|
byte[] bArr = N.a;
|
2021-10-29 07:19:59 +00:00
|
|
|
int i2 = N.f3033c;
|
2021-10-15 06:18:26 +00:00
|
|
|
i = deflater.deflate(bArr, i2, 8192 - i2, 2);
|
2021-08-03 07:33:18 +00:00
|
|
|
} else {
|
2021-10-15 06:18:26 +00:00
|
|
|
Deflater deflater2 = this.k;
|
|
|
|
byte[] bArr2 = N.a;
|
2021-10-29 07:19:59 +00:00
|
|
|
int i3 = N.f3033c;
|
2021-10-15 06:18:26 +00:00
|
|
|
i = deflater2.deflate(bArr2, i3, 8192 - i3);
|
|
|
|
}
|
|
|
|
if (i > 0) {
|
2021-10-29 07:19:59 +00:00
|
|
|
N.f3033c += i;
|
2021-10-15 06:18:26 +00:00
|
|
|
g.j += (long) i;
|
|
|
|
this.j.E();
|
|
|
|
} else if (this.k.needsInput()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-29 07:19:59 +00:00
|
|
|
if (N.b == N.f3033c) {
|
2021-10-15 06:18:26 +00:00
|
|
|
g.i = N.a();
|
|
|
|
t.a(N);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // f0.v, java.io.Closeable, java.lang.AutoCloseable
|
|
|
|
public void close() throws IOException {
|
|
|
|
if (!this.i) {
|
|
|
|
Throwable th = null;
|
|
|
|
try {
|
|
|
|
this.k.finish();
|
|
|
|
a(false);
|
|
|
|
} catch (Throwable th2) {
|
|
|
|
th = th2;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.k.end();
|
|
|
|
} catch (Throwable th3) {
|
|
|
|
if (th == null) {
|
|
|
|
th = th3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.j.close();
|
|
|
|
} catch (Throwable th4) {
|
|
|
|
if (th == null) {
|
|
|
|
th = th4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.i = true;
|
|
|
|
if (th != null) {
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // f0.v, java.io.Flushable
|
|
|
|
public void flush() throws IOException {
|
|
|
|
a(true);
|
|
|
|
this.j.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // f0.v
|
|
|
|
public y timeout() {
|
|
|
|
return this.j.timeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Object
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder O = a.O("DeflaterSink(");
|
|
|
|
O.append(this.j);
|
|
|
|
O.append(')');
|
|
|
|
return O.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // f0.v
|
|
|
|
public void write(e eVar, long j) throws IOException {
|
|
|
|
m.checkParameterIsNotNull(eVar, "source");
|
|
|
|
c.q.a.k.a.l(eVar.j, 0, j);
|
|
|
|
while (j > 0) {
|
|
|
|
s sVar = eVar.i;
|
|
|
|
if (sVar == null) {
|
|
|
|
m.throwNpe();
|
|
|
|
}
|
2021-10-29 07:19:59 +00:00
|
|
|
int min = (int) Math.min(j, (long) (sVar.f3033c - sVar.b));
|
2021-10-15 06:18:26 +00:00
|
|
|
this.k.setInput(sVar.a, sVar.b, min);
|
|
|
|
a(false);
|
|
|
|
long j2 = (long) min;
|
|
|
|
eVar.j -= j2;
|
|
|
|
int i = sVar.b + min;
|
|
|
|
sVar.b = i;
|
2021-10-29 07:19:59 +00:00
|
|
|
if (i == sVar.f3033c) {
|
2021-10-15 06:18:26 +00:00
|
|
|
eVar.i = sVar.a();
|
|
|
|
t.a(sVar);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-10-15 06:18:26 +00:00
|
|
|
j -= j2;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|