2021-08-03 07:33:18 +00:00
|
|
|
package g0;
|
|
|
|
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import d0.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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-08-27 06:37:59 +00:00
|
|
|
int i2 = N.f2853c;
|
2021-08-03 07:33:18 +00:00
|
|
|
i = deflater.deflate(bArr, i2, 8192 - i2, 2);
|
|
|
|
} else {
|
|
|
|
Deflater deflater2 = this.k;
|
|
|
|
byte[] bArr2 = N.a;
|
2021-08-27 06:37:59 +00:00
|
|
|
int i3 = N.f2853c;
|
2021-08-03 07:33:18 +00:00
|
|
|
i = deflater2.deflate(bArr2, i3, 8192 - i3);
|
|
|
|
}
|
|
|
|
if (i > 0) {
|
2021-08-27 06:37:59 +00:00
|
|
|
N.f2853c += i;
|
2021-08-03 07:33:18 +00:00
|
|
|
g.j += (long) i;
|
|
|
|
this.j.E();
|
|
|
|
} else if (this.k.needsInput()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-08-27 06:37:59 +00:00
|
|
|
if (N.b == N.f2853c) {
|
2021-08-03 07:33:18 +00:00
|
|
|
g.i = N.a();
|
|
|
|
t.a(N);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.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 // g0.v, java.io.Flushable
|
|
|
|
public void flush() throws IOException {
|
|
|
|
a(true);
|
|
|
|
this.j.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.v
|
|
|
|
public y timeout() {
|
|
|
|
return this.j.timeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Object
|
|
|
|
public String toString() {
|
2021-08-25 07:02:36 +00:00
|
|
|
StringBuilder N = a.N("DeflaterSink(");
|
|
|
|
N.append(this.j);
|
|
|
|
N.append(')');
|
|
|
|
return N.toString();
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.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-08-27 06:37:59 +00:00
|
|
|
int min = (int) Math.min(j, (long) (sVar.f2853c - sVar.b));
|
2021-08-03 07:33:18 +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-08-27 06:37:59 +00:00
|
|
|
if (i == sVar.f2853c) {
|
2021-08-03 07:33:18 +00:00
|
|
|
eVar.i = sVar.a();
|
|
|
|
t.a(sVar);
|
|
|
|
}
|
|
|
|
j -= j2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|