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

132 lines
3.5 KiB
Java

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;
int i2 = N.f2794c;
i = deflater.deflate(bArr, i2, 8192 - i2, 2);
} else {
Deflater deflater2 = this.k;
byte[] bArr2 = N.a;
int i3 = N.f2794c;
i = deflater2.deflate(bArr2, i3, 8192 - i3);
}
if (i > 0) {
N.f2794c += i;
g.j += (long) i;
this.j.E();
} else if (this.k.needsInput()) {
break;
}
}
if (N.b == N.f2794c) {
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() {
StringBuilder K = a.K("DeflaterSink(");
K.append(this.j);
K.append(')');
return K.toString();
}
@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();
}
int min = (int) Math.min(j, (long) (sVar.f2794c - sVar.b));
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;
if (i == sVar.f2794c) {
eVar.i = sVar.a();
t.a(sVar);
}
j -= j2;
}
}
}