package f.y;

import com.cvte.vman.instance.InvokeCmd;
import f.e0.t;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: Utils.kt */
/* JADX INFO: loaded from: classes.dex */
public class j extends i {
    public static final File i(File file, File file2, boolean z, int i2) throws IOException {
        f.z.d.k.e(file, "<this>");
        f.z.d.k.e(file2, "target");
        if (!file.exists()) {
            throw new l(file, null, "The source file doesn't exist.", 2, null);
        }
        if (file2.exists()) {
            if (!z) {
                throw new d(file, file2, "The destination file already exists.");
            }
            if (!file2.delete()) {
                throw new d(file, file2, "Tried to overwrite the destination, but failed to delete it.");
            }
        }
        if (!file.isDirectory()) {
            File parentFile = file2.getParentFile();
            if (parentFile != null) {
                parentFile.mkdirs();
            }
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                FileOutputStream fileOutputStream = new FileOutputStream(file2);
                try {
                    a.a(fileInputStream, fileOutputStream, i2);
                    b.a(fileOutputStream, null);
                    b.a(fileInputStream, null);
                } finally {
                }
            } finally {
            }
        } else if (!file2.mkdirs()) {
            throw new e(file, file2, "Failed to create target directory.");
        }
        return file2;
    }

    public static /* synthetic */ File j(File file, File file2, boolean z, int i2, int i3, Object obj) throws IOException {
        if ((i3 & 2) != 0) {
            z = false;
        }
        if ((i3 & 4) != 0) {
            i2 = InvokeCmd.CMD_TOUCH_CTRL_START;
        }
        i(file, file2, z, i2);
        return file2;
    }

    public static String k(File file) {
        f.z.d.k.e(file, "<this>");
        String name = file.getName();
        f.z.d.k.d(name, "name");
        return t.c0(name, ".", null, 2, null);
    }
}
