package defpackage;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

/* renamed from: ᵖᵯᵮˉ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2397 extends RandomAccessFile {

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final String f9344;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final File[] f9345;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public int f9346;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final long f9347;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final byte[] f9348;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public RandomAccessFile f9349;

    public C2397(File file, File[] fileArr) throws IOException {
        super(file, "r");
        this.f9348 = new byte[1];
        this.f9346 = 0;
        super.close();
        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) {
                C0910.m3045(AbstractC4486.m9550("Split file extension not in expected format. Found: ", strSubstring, " expected of format: .001, .002, etc"));
                throw null;
            }
        }
        this.f9349 = new RandomAccessFile(file, "r");
        this.f9345 = fileArr;
        this.f9347 = file.length();
        this.f9344 = "r";
    }

    @Override // java.io.RandomAccessFile, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        RandomAccessFile randomAccessFile = this.f9349;
        if (randomAccessFile != null) {
            randomAccessFile.close();
        }
        super.close();
    }

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

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

    @Override // java.io.RandomAccessFile
    public final int read() {
        byte[] bArr = this.f9348;
        if (read(bArr, 0, bArr.length) == -1) {
            return -1;
        }
        return bArr[0] & 255;
    }

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

    @Override // java.io.RandomAccessFile
    public final int read(byte[] bArr, int i, int i2) throws IOException {
        int i3 = this.f9349.read(bArr, i, i2);
        if (i3 != -1) {
            return i3;
        }
        int i4 = this.f9346;
        if (i4 == this.f9345.length - 1) {
            return -1;
        }
        m6156(i4 + 1);
        return read(bArr, i, i2);
    }

    @Override // java.io.RandomAccessFile
    public final void seek(long j) throws IOException {
        long j2 = this.f9347;
        int i = (int) (j / j2);
        if (i != this.f9346) {
            m6156(i);
        }
        this.f9349.seek(j - (i * j2));
    }

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

    @Override // java.io.RandomAccessFile, java.io.DataOutput
    public final void write(byte[] bArr) {
        write(bArr, 0, bArr.length);
        throw null;
    }

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

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m6156(int i) throws IOException {
        if (this.f9346 == i) {
            return;
        }
        File[] fileArr = this.f9345;
        if (i > fileArr.length - 1) {
            C0910.m3045("split counter greater than number of split files");
            return;
        }
        RandomAccessFile randomAccessFile = this.f9349;
        if (randomAccessFile != null) {
            randomAccessFile.close();
        }
        this.f9349 = new RandomAccessFile(fileArr[i], this.f9344);
        this.f9346 = i;
    }
}
