package com.epson.cameracopy.alt;

import android.content.Context;
import android.os.Environment;

import epson.common.ExternalFileUtils;
import java.io.File;

public class FileUtils {
    public static final String TEMPRARY_DIRECOTRY = "tempCamera";

    public static boolean checkExternalStorage() {
        return "mounted".equals(Environment.getExternalStorageState());
    }

    public static File getNewTemporaryJpegFile(@NonNull Context context) {
        File file = new File(getCameracopyTempDir(context).getPath(), "temp.jpg");
        if (file.exists()) {
            file.delete();
        }
        return file;
    }

    @NonNull
    public static File getCameracopyTempDir(@NonNull Context context) {
        File file = new File(context.getExternalCacheDir(), TEMPRARY_DIRECOTRY);
        ExternalFileUtils.getInstance(context).createTempFolder(file.getPath());
        return file;
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x003a A[SYNTHETIC, Splitter:B:23:0x003a] */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x0041 A[SYNTHETIC, Splitter:B:27:0x0041] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static void copy(java.io.File r9, java.io.File r10) throws java.io.IOException {
        /*
            r0 = 0
            java.io.FileInputStream r1 = new java.io.FileInputStream     // Catch:{ all -> 0x0036 }
            r1.<init>(r9)     // Catch:{ all -> 0x0036 }
            java.nio.channels.FileChannel r9 = r1.getChannel()     // Catch:{ all -> 0x0036 }
            java.io.FileOutputStream r1 = new java.io.FileOutputStream     // Catch:{ all -> 0x0030 }
            r1.<init>(r10)     // Catch:{ all -> 0x0030 }
            java.nio.channels.FileChannel r10 = r1.getChannel()     // Catch:{ all -> 0x0030 }
            r3 = 0
            long r5 = r9.size()     // Catch:{ all -> 0x002b }
            r2 = r9
            r7 = r10
            r2.transferTo(r3, r5, r7)     // Catch:{ all -> 0x002b }
            if (r9 == 0) goto L_0x0025
            r9.close()     // Catch:{ IOException -> 0x0024 }
            goto L_0x0025
        L_0x0024:
        L_0x0025:
            if (r10 == 0) goto L_0x002a
            r10.close()     // Catch:{ IOException -> 0x002a }
        L_0x002a:
            return
        L_0x002b:
            r0 = move-exception
            r8 = r0
            r0 = r9
            r9 = r8
            goto L_0x0038
        L_0x0030:
            r10 = move-exception
            r8 = r0
            r0 = r9
            r9 = r10
            r10 = r8
            goto L_0x0038
        L_0x0036:
            r9 = move-exception
            r10 = r0
        L_0x0038:
            if (r0 == 0) goto L_0x003f
            r0.close()     // Catch:{ IOException -> 0x003e }
            goto L_0x003f
        L_0x003e:
        L_0x003f:
            if (r10 == 0) goto L_0x0044
            r10.close()     // Catch:{ IOException -> 0x0044 }
        L_0x0044:
            throw r9
        */
        throw new UnsupportedOperationException("Method not decompiled: com.epson.cameracopy.alt.FileUtils.copy(java.io.File, java.io.File):void");
    }
}
