package o;

import java.nio.ByteBuffer;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.k00, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1632k00 implements InterfaceC1592jf {
    public final R80 l;
    public final C0732af m = new C0732af();
    public boolean n;

    public C1632k00(R80 r80) {
        this.l = r80;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf F(int i, byte[] bArr) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.z(i, bArr);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf J(String str) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.V(str);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf K(long j) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.M(j);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final long N(T90 t90) {
        long j = 0;
        while (true) {
            long jC = ((M9) t90).C(8192L, this.m);
            if (jC == -1) {
                return j;
            }
            j += jC;
            b();
        }
    }

    @Override // o.R80
    public final Cf0 a() {
        return this.l.a();
    }

    public final InterfaceC1592jf b() {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        C0732af c0732af = this.m;
        long jC = c0732af.c();
        if (jC > 0) {
            this.l.e(jC, c0732af);
        }
        return this;
    }

    @Override // o.R80, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws Throwable {
        R80 r80 = this.l;
        if (this.n) {
            return;
        }
        try {
            C0732af c0732af = this.m;
            long j = c0732af.m;
            if (j > 0) {
                r80.e(j, c0732af);
            }
            th = null;
        } catch (Throwable th) {
            th = th;
        }
        try {
            r80.close();
        } catch (Throwable th2) {
            if (th == null) {
                th = th2;
            }
        }
        this.n = true;
        if (th != null) {
            throw th;
        }
    }

    @Override // o.R80
    public final void e(long j, C0732af c0732af) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.e(j, c0732af);
        b();
    }

    @Override // o.InterfaceC1592jf, o.R80, java.io.Flushable
    public final void flush() {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        C0732af c0732af = this.m;
        long j = c0732af.m;
        R80 r80 = this.l;
        if (j > 0) {
            r80.e(j, c0732af);
        }
        r80.flush();
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf h(long j) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.R(j);
        b();
        return this;
    }

    @Override // java.nio.channels.Channel
    public final boolean isOpen() {
        return !this.n;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf o(C0135Ff c0135Ff) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.D(c0135Ff);
        b();
        return this;
    }

    public final String toString() {
        return "buffer(" + this.l + ')';
    }

    @Override // java.nio.channels.WritableByteChannel
    public final int write(ByteBuffer byteBuffer) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        int iWrite = this.m.write(byteBuffer);
        b();
        return iWrite;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf writeByte(int i) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.G(i);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf writeInt(int i) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.S(i);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf writeShort(int i) {
        if (this.n) {
            throw new IllegalStateException("closed");
        }
        this.m.T(i);
        b();
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf write(byte[] bArr) {
        if (!this.n) {
            this.m.z(bArr.length, bArr);
            b();
            return this;
        }
        throw new IllegalStateException("closed");
    }
}
