2021-11-08 18:25:28 +00:00
|
|
|
package g0;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.d.b.a.a;
|
2021-11-08 18:25:28 +00:00
|
|
|
import d0.z.d.m;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import okio.BufferedSink;
|
|
|
|
import okio.ByteString;
|
|
|
|
/* compiled from: RealBufferedSink.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-11-08 18:25:28 +00:00
|
|
|
public final class q implements BufferedSink {
|
2021-12-17 22:03:14 +00:00
|
|
|
public final e j = new e();
|
|
|
|
public boolean k;
|
|
|
|
public final v l;
|
2021-11-08 18:25:28 +00:00
|
|
|
|
|
|
|
public q(v vVar) {
|
|
|
|
m.checkParameterIsNotNull(vVar, "sink");
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l = vVar;
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink F() {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
long f = this.j.f();
|
2021-11-08 18:25:28 +00:00
|
|
|
if (f > 0) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.write(this.j, f);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink K(String str) {
|
|
|
|
m.checkParameterIsNotNull(str, "string");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.b0(str);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public long P(x xVar) {
|
|
|
|
m.checkParameterIsNotNull(xVar, "source");
|
|
|
|
long j = 0;
|
|
|
|
while (true) {
|
2022-03-02 20:59:20 +00:00
|
|
|
long i02 = ((n) xVar).i0(this.j, 8192);
|
2021-11-08 18:25:28 +00:00
|
|
|
if (i02 == -1) {
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
j += i02;
|
|
|
|
F();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink Q(long j) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.Q(j);
|
2021-11-08 18:25:28 +00:00
|
|
|
return F();
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.v, java.io.Closeable, java.lang.AutoCloseable
|
|
|
|
public void close() {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
2021-11-08 18:25:28 +00:00
|
|
|
Throwable th = null;
|
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
e eVar = this.j;
|
|
|
|
long j = eVar.k;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (j > 0) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.write(eVar, j);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
} catch (Throwable th2) {
|
|
|
|
th = th2;
|
|
|
|
}
|
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.close();
|
2021-11-08 18:25:28 +00:00
|
|
|
} catch (Throwable th3) {
|
2022-03-02 20:59:20 +00:00
|
|
|
th = th3;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (th == null) {
|
|
|
|
}
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
this.k = true;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (th != null) {
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink e0(ByteString byteString) {
|
|
|
|
m.checkParameterIsNotNull(byteString, "byteString");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.O(byteString);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink, g0.v, java.io.Flushable
|
|
|
|
public void flush() {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
e eVar = this.j;
|
|
|
|
long j = eVar.k;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (j > 0) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.write(eVar, j);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.flush();
|
2021-11-08 18:25:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public e g() {
|
2021-12-17 22:03:14 +00:00
|
|
|
return this.j;
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.nio.channels.Channel
|
|
|
|
public boolean isOpen() {
|
2021-12-17 22:03:14 +00:00
|
|
|
return !this.k;
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink p() {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
e eVar = this.j;
|
|
|
|
long j = eVar.k;
|
2021-11-08 18:25:28 +00:00
|
|
|
if (j > 0) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l.write(eVar, j);
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink q0(long j) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.q0(j);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.v
|
|
|
|
public y timeout() {
|
2021-12-17 22:03:14 +00:00
|
|
|
return this.l.timeout();
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2022-03-22 15:40:06 +00:00
|
|
|
StringBuilder S = a.S("buffer(");
|
|
|
|
S.append(this.l);
|
|
|
|
S.append(')');
|
|
|
|
return S.toString();
|
2021-11-08 18:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.nio.channels.WritableByteChannel
|
|
|
|
public int write(ByteBuffer byteBuffer) {
|
|
|
|
m.checkParameterIsNotNull(byteBuffer, "source");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
int write = this.j.write(byteBuffer);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return write;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink write(byte[] bArr) {
|
|
|
|
m.checkParameterIsNotNull(bArr, "source");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.R(bArr);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink write(byte[] bArr, int i, int i2) {
|
|
|
|
m.checkParameterIsNotNull(bArr, "source");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.S(bArr, i, i2);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // g0.v
|
|
|
|
public void write(e eVar, long j) {
|
|
|
|
m.checkParameterIsNotNull(eVar, "source");
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.write(eVar, j);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink writeByte(int i) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.T(i);
|
2021-11-08 18:25:28 +00:00
|
|
|
return F();
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink writeInt(int i) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.W(i);
|
2021-11-08 18:25:28 +00:00
|
|
|
return F();
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okio.BufferedSink
|
|
|
|
public BufferedSink writeShort(int i) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.k) {
|
|
|
|
this.j.X(i);
|
2021-11-08 18:25:28 +00:00
|
|
|
F();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("closed".toString());
|
|
|
|
}
|
|
|
|
}
|