package defpackage;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import net.lingala.zip4j.exception.ZipException;

/* renamed from: ˏˆʿ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1825 implements Closeable {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public C4348 f7413;

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

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

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final C3944 f7417;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final ᵧˉʙ f7414 = new ᵧˉʙ(19);

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public int f7412 = 4096;

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final ArrayList f7410 = new ArrayList();

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public final boolean f7411 = true;

    public C1825(File file, char[] cArr) {
        if (file == null) {
            ᵹˉᵞ.ˌᵜᵹᵩ("input zip file parameter is null");
            throw null;
        }
        this.f7415 = file;
        this.f7416 = cArr;
        this.f7417 = new C3944();
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        ArrayList arrayList = this.f7410;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            ((InputStream) obj).close();
        }
        arrayList.clear();
    }

    public final String toString() {
        return this.f7415.toString();
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final RandomAccessFile m5175() throws IOException {
        File file = this.f7415;
        if (!file.getName().endsWith(".zip.001")) {
            return new RandomAccessFile(file, "r");
        }
        C2397 c2397 = new C2397(file, AbstractC4618.m9782(file));
        c2397.m6156(c2397.f9345.length - 1);
        return c2397;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m5176(String str) throws IOException {
        ᵬˆˀᵣ r0 = new ᵬˆˀᵣ(13);
        if (!ᵙᵛᵯ.ᵢˇᵭ(str)) {
            C0190.m1425("output path is null or invalid");
            return;
        }
        File file = new File(str);
        if (file.exists()) {
            if (!file.isDirectory()) {
                C0190.m1425("output directory is not valid");
                return;
            }
        } else if (!file.mkdirs()) {
            C0190.m1425("Cannot create output directories");
            return;
        }
        if (this.f7413 == null) {
            m5177();
        }
        C4348 c4348 = this.f7413;
        if (c4348 == null) {
            C0190.m1425("Internal error occurred when extracting zip file");
        } else {
            new C4488(c4348, this.f7416, r0, new C3718(this.f7417)).ᵶᵷᵕ(new C3798(str, new C2723(this.f7412, this.f7411)));
        }
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public final void m5177() throws IOException {
        if (this.f7413 != null) {
            return;
        }
        File file = this.f7415;
        if (!file.exists()) {
            C4348 c4348 = new C4348();
            this.f7413 = c4348;
            c4348.f16271 = file;
        } else {
            if (!file.canRead()) {
                C0190.m1425("no read access for the input zip file");
                return;
            }
            try {
                RandomAccessFile randomAccessFileM5175 = m5175();
                try {
                    C4348 c43482 = new ʽᵡ(19).ˌᵹᵨˑ(randomAccessFileM5175, new C2723(this.f7412, this.f7411));
                    this.f7413 = c43482;
                    c43482.f16271 = file;
                    randomAccessFileM5175.close();
                } finally {
                }
            } catch (ZipException e) {
                throw e;
            } catch (IOException e2) {
                throw new ZipException(e2);
            }
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m5178(List list, C5254 c5254) throws IOException {
        if (list == null || list.size() == 0) {
            C0190.m1425("input file List is null or empty");
            return;
        }
        m5177();
        if (this.f7413 == null) {
            C0190.m1425("internal error: zip model is null");
            return;
        }
        if (this.f7415.exists() && this.f7413.f16272) {
            C0190.m1425("Zip file already exists. Zip file format does not allow updating split/spanned files");
            return;
        }
        new C1337(this.f7413, this.f7416, this.f7414, new C3718(this.f7417)).ᵶᵷᵕ(new C3121(list, c5254, new C2723(this.f7412, this.f7411)));
    }
}
