package p421.p433.p434.p439.p440;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import p138.p139.p143.p144.C2803;
import p421.p433.p434.p442.p443.EnumC6836;

/* JADX INFO: renamed from: ޏ.ؠ.֏.ށ.֏.ބ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6796 extends RandomAccessFile {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public long f19666;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public File[] f19667;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public RandomAccessFile f19668;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public byte[] f19669;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public int f19670;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public String f19671;

    public C6796(File file, String str, File[] fileArr) throws IOException {
        super(file, str);
        this.f19669 = new byte[1];
        this.f19670 = 0;
        super.close();
        if (EnumC6836.WRITE.f19843.equals(str)) {
            throw new IllegalArgumentException("write mode is not allowed for NumberedSplitRandomAccessFile");
        }
        int i = 1;
        for (File file2 : fileArr) {
            String name = file2.getName();
            String strSubstring = !name.contains(".") ? "" : name.substring(name.lastIndexOf(".") + 1);
            try {
                if (i != Integer.parseInt(strSubstring)) {
                    throw new IOException("Split file number " + i + " does not exist");
                }
                i++;
            } catch (NumberFormatException unused) {
                throw new IOException(C2803.m4880("Split file extension not in expected format. Found: ", strSubstring, " expected of format: .001, .002, etc"));
            }
        }
        this.f19668 = new RandomAccessFile(file, str);
        this.f19667 = fileArr;
        this.f19666 = file.length();
        this.f19671 = str;
    }

    @Override // java.io.RandomAccessFile
    public long getFilePointer() {
        return this.f19668.getFilePointer();
    }

    @Override // java.io.RandomAccessFile
    public long length() {
        return this.f19668.length();
    }

    @Override // java.io.RandomAccessFile
    public int read() {
        if (read(this.f19669) == -1) {
            return -1;
        }
        return this.f19669[0] & 255;
    }

    @Override // java.io.RandomAccessFile
    public int read(byte[] bArr) {
        return read(bArr, 0, bArr.length);
    }

    @Override // java.io.RandomAccessFile
    public int read(byte[] bArr, int i, int i2) throws IOException {
        int i3 = this.f19668.read(bArr, i, i2);
        if (i3 != -1) {
            return i3;
        }
        int i4 = this.f19670;
        if (i4 == this.f19667.length - 1) {
            return -1;
        }
        m9964(i4 + 1);
        return read(bArr, i, i2);
    }

    @Override // java.io.RandomAccessFile
    public void seek(long j) throws IOException {
        int i = (int) (j / this.f19666);
        if (i != this.f19670) {
            m9964(i);
        }
        this.f19668.seek(j - (((long) i) * this.f19666));
    }

    @Override // java.io.RandomAccessFile, java.io.DataOutput
    public void write(int i) {
        throw new UnsupportedOperationException();
    }

    @Override // java.io.RandomAccessFile, java.io.DataOutput
    public void write(byte[] bArr) {
        int length = bArr.length;
        throw new UnsupportedOperationException();
    }

    @Override // java.io.RandomAccessFile, java.io.DataOutput
    public void write(byte[] bArr, int i, int i2) {
        throw new UnsupportedOperationException();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m9964(int i) throws IOException {
        if (this.f19670 == i) {
            return;
        }
        if (i > this.f19667.length - 1) {
            throw new IOException("split counter greater than number of split files");
        }
        RandomAccessFile randomAccessFile = this.f19668;
        if (randomAccessFile != null) {
            randomAccessFile.close();
        }
        this.f19668 = new RandomAccessFile(this.f19667[i], this.f19671);
        this.f19670 = i;
    }
}
