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;

/* JADX INFO: renamed from: ᵪᵣʿˏ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3920 implements Closeable {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final File f14959;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final C3442 f14961;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public C1411 f14962;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final char[] f14963;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final ᵣˊˈᵪ f14964 = new ᵣˊˈᵪ(19);

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public int f14965 = 4096;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final ArrayList f14958 = new ArrayList();

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final boolean f14960 = true;

    public C3920(File file, char[] cArr) {
        if (file == null) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("input zip file parameter is null");
            throw null;
        }
        this.f14959 = file;
        this.f14963 = cArr;
        this.f14961 = new C3442();
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        ArrayList arrayList = this.f14958;
        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.f14959.toString();
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m8649(String str) throws ZipException {
        ᵤᵮᵨ r0 = new ᵤᵮᵨ(13);
        if (!ᵺᵘ.ᵸˆˁ(str)) {
            C4468.m9508("output path is null or invalid");
            return;
        }
        File file = new File(str);
        if (file.exists()) {
            if (!file.isDirectory()) {
                C4468.m9508("output directory is not valid");
                return;
            }
        } else if (!file.mkdirs()) {
            C4468.m9508("Cannot create output directories");
            return;
        }
        if (this.f14962 == null) {
            m8651();
        }
        C1411 c1411 = this.f14962;
        if (c1411 == null) {
            C4468.m9508("Internal error occurred when extracting zip file");
        } else {
            new C2756(c1411, this.f14963, r0, new C1014(this.f14961)).ᵱᵽʡᵚ(new C5275(str, new C3185(this.f14965, this.f14960)));
        }
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final RandomAccessFile m8650() throws IOException {
        File file = this.f14959;
        if (!file.getName().endsWith(".zip.001")) {
            return new RandomAccessFile(file, "r");
        }
        C3577 c3577 = new C3577(file, ˁᵨᵦ.ᵷᵺʾᵖ(file));
        c3577.m8085(c3577.f13665.length - 1);
        return c3577;
    }

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public final void m8651() throws ZipException {
        if (this.f14962 != null) {
            return;
        }
        File file = this.f14959;
        if (!file.exists()) {
            C1411 c1411 = new C1411();
            this.f14962 = c1411;
            c1411.f5820 = file;
        } else {
            if (!file.canRead()) {
                C4468.m9508("no read access for the input zip file");
                return;
            }
            try {
                RandomAccessFile randomAccessFileM8650 = m8650();
                try {
                    C1411 c14112 = new ᵯᵨᵲ(19).ˁᵺˈ(randomAccessFileM8650, new C3185(this.f14965, this.f14960));
                    this.f14962 = c14112;
                    c14112.f5820 = file;
                    randomAccessFileM8650.close();
                } finally {
                }
            } catch (ZipException e) {
                throw e;
            } catch (IOException e2) {
                throw new ZipException(e2);
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m8652(List list, C4577 c4577) throws ZipException {
        if (list == null || list.size() == 0) {
            C4468.m9508("input file List is null or empty");
            return;
        }
        m8651();
        if (this.f14962 == null) {
            C4468.m9508("internal error: zip model is null");
            return;
        }
        if (this.f14959.exists() && this.f14962.f5825) {
            C4468.m9508("Zip file already exists. Zip file format does not allow updating split/spanned files");
            return;
        }
        new C1161(this.f14962, this.f14963, this.f14964, new C1014(this.f14961)).ᵱᵽʡᵚ(new C0503(list, c4577, new C3185(this.f14965, this.f14960)));
    }
}
