package com.google.android.play.core.d;

import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.android.play.core.b.bf;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Set;
import java.util.zip.ZipFile;

public final class h implements j {
    public final /* synthetic */ Set LIZ;
    public final /* synthetic */ r LIZIZ;
    public final /* synthetic */ ZipFile LIZJ;

    static {
        Covode.recordClassIndex(44325);
    }

    public h(Set set, r rVar, ZipFile zipFile) {
        this.LIZ = set;
        this.LIZIZ = rVar;
        this.LIZJ = zipFile;
    }

    public final void LIZ(k kVar, File file, boolean z) {
        FileOutputStream fileOutputStream;
        MethodCollector.i(12347);
        this.LIZ.add(file);
        if (!z) {
            Object[] objArr = new Object[5];
            String str = this.LIZIZ.LIZIZ;
            String str2 = kVar.LIZ;
            this.LIZIZ.LIZ.getAbsolutePath();
            kVar.LIZIZ.getName();
            file.getAbsolutePath();
            byte[] bArr = new byte[4096];
            InputStream inputStream = this.LIZJ.getInputStream(kVar.LIZIZ);
            try {
                fileOutputStream = new FileOutputStream(file);
                while (true) {
                    int read = inputStream.read(bArr);
                    if (read > 0) {
                        fileOutputStream.write(bArr, 0, read);
                    } else {
                        fileOutputStream.close();
                        inputStream.close();
                        MethodCollector.o(12347);
                        return;
                    }
                }
            } catch (Throwable th) {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (Throwable th2) {
                        bf.LIZ(th, th2);
                    }
                }
                MethodCollector.o(12347);
                throw th;
            }
        } else {
            MethodCollector.o(12347);
            return;
        }
        MethodCollector.o(12347);
        throw th;
    }
}
