package o;

import java.io.IOException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.az, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0770az extends LB {
    public final long m;
    public final boolean n;

    /* renamed from: o, reason: collision with root package name */
    public long f454o;

    public C0770az(T90 t90, long j, boolean z) {
        super(t90);
        this.m = j;
        this.n = z;
    }

    @Override // o.T90
    public final long C(long j, C0732af c0732af) throws IOException {
        long j2 = this.f454o;
        long j3 = this.m;
        if (j2 > j3) {
            j = 0;
        } else if (this.n) {
            long j4 = j3 - j2;
            if (j4 == 0) {
                return -1L;
            }
            j = Math.min(j, j4);
        }
        long jC = this.l.C(j, c0732af);
        if (jC != -1) {
            this.f454o += jC;
        }
        long j5 = this.f454o;
        if ((j5 >= j3 || jC != -1) && j5 <= j3) {
            return jC;
        }
        if (jC > 0 && j5 > j3) {
            long j6 = c0732af.m - (j5 - j3);
            C0732af c0732af2 = new C0732af();
            c0732af2.N(c0732af);
            c0732af.e(j6, c0732af2);
            c0732af2.b();
        }
        throw new IOException("expected " + j3 + " bytes but got " + this.f454o);
    }
}
