package o; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import kotlin.io.FileAlreadyExistsException; import kotlin.io.FileSystemException; import kotlin.io.NoSuchFileException; /* loaded from: classes6.dex */ public class gbI extends gbM { public static final File d(File file, File file2) { C14957gcv.e(file, ""); C14957gcv.e(file2, ""); if (!file.exists()) { throw new NoSuchFileException(file, "The source file doesn't exist."); } if (file2.exists() && !file2.delete()) { throw new FileAlreadyExistsException(file, file2, "Tried to overwrite the destination, but failed to delete it."); } if (file.isDirectory()) { if (!file2.mkdirs()) { throw new FileSystemException(file, file2, "Failed to create target directory."); } } else { File parentFile = file2.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } FileOutputStream fileInputStream = new FileInputStream(file); try { FileInputStream fileInputStream2 = fileInputStream; fileInputStream = new FileOutputStream(file2); try { gbH.e(fileInputStream2, fileInputStream, 8192); gbF.d(fileInputStream, null); gbF.d(fileInputStream, null); } finally { } } finally { } } return file2; } }