package p5;

import androidx.navigation.C1134i;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.util.Iterator;
import java.util.List;
import n2.AbstractC2613d;
import x4.C3249o;

/* JADX INFO: renamed from: p5.t, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC2749t implements Closeable {
    public static final C2748s Companion = new C2748s();
    public static final AbstractC2749t RESOURCES;
    public static final AbstractC2749t SYSTEM;
    public static final G SYSTEM_TEMPORARY_DIRECTORY;

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r3v3, types: [java.lang.Throwable] */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX WARN: Type inference failed for: r3v7 */
    /* JADX WARN: Type inference failed for: r3v8 */
    /* JADX WARN: Type inference failed for: r4v0, types: [J4.c, java.lang.Object] */
    /* JADX INFO: renamed from: -write$default, reason: not valid java name */
    public static /* synthetic */ Object m1212write$default(AbstractC2749t abstractC2749t, G file, boolean z6, J4.c writerAction, int i6, Object obj) {
        ?? r32;
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: write");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        kotlin.jvm.internal.o.h(file, "file");
        kotlin.jvm.internal.o.h(writerAction, "writerAction");
        I iB = AbstractC2732b.b(abstractC2749t.sink(file, z6));
        Object th = null;
        try {
            Object objInvoke = writerAction.invoke(iB);
            try {
                iB.close();
            } catch (Throwable th2) {
                th = th2;
            }
            r32 = th;
            th = objInvoke;
        } catch (Throwable th3) {
            try {
                iB.close();
                r32 = th3;
            } catch (Throwable th4) {
                AbstractC2613d.b(th3, th4);
                r32 = th3;
            }
        }
        if (r32 == 0) {
            return th;
        }
        throw r32;
    }

    static {
        AbstractC2749t b5;
        try {
            Class.forName("java.nio.file.Files");
            b5 = new D();
        } catch (ClassNotFoundException unused) {
            b5 = new B();
        }
        SYSTEM = b5;
        String str = G.f23047b;
        String property = System.getProperty("java.io.tmpdir");
        kotlin.jvm.internal.o.g(property, "getProperty(...)");
        SYSTEM_TEMPORARY_DIRECTORY = C1134i.o(property, false);
        ClassLoader classLoader = q5.i.class.getClassLoader();
        kotlin.jvm.internal.o.g(classLoader, "getClassLoader(...)");
        RESOURCES = new q5.i(classLoader);
    }

    public static /* synthetic */ N appendingSink$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: appendingSink");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        return abstractC2749t.appendingSink(g6, z6);
    }

    public static /* synthetic */ void createDirectories$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) throws IOException {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: createDirectories");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        abstractC2749t.createDirectories(g6, z6);
    }

    public static /* synthetic */ void createDirectory$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: createDirectory");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        abstractC2749t.createDirectory(g6, z6);
    }

    public static /* synthetic */ void delete$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: delete");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        abstractC2749t.delete(g6, z6);
    }

    public static /* synthetic */ void deleteRecursively$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: deleteRecursively");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        abstractC2749t.deleteRecursively(g6, z6);
    }

    public static final AbstractC2749t get(FileSystem fileSystem) {
        Companion.getClass();
        kotlin.jvm.internal.o.h(fileSystem, "<this>");
        return new C(fileSystem);
    }

    public static /* synthetic */ R4.k listRecursively$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: listRecursively");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        return abstractC2749t.listRecursively(g6, z6);
    }

    public static /* synthetic */ AbstractC2747q openReadWrite$default(AbstractC2749t abstractC2749t, G g6, boolean z6, boolean z7, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: openReadWrite");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        if ((i6 & 4) != 0) {
            z7 = false;
        }
        return abstractC2749t.openReadWrite(g6, z6, z7);
    }

    public static /* synthetic */ N sink$default(AbstractC2749t abstractC2749t, G g6, boolean z6, int i6, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: sink");
        }
        if ((i6 & 2) != 0) {
            z6 = false;
        }
        return abstractC2749t.sink(g6, z6);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r4v0, types: [J4.c, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r4v2, types: [java.lang.Throwable] */
    /* JADX WARN: Type inference failed for: r4v4 */
    /* JADX WARN: Type inference failed for: r4v5 */
    /* JADX WARN: Type inference failed for: r4v6 */
    /* JADX INFO: renamed from: -read, reason: not valid java name */
    public final <T> T m1213read(G file, J4.c readerAction) {
        ?? r42;
        kotlin.jvm.internal.o.h(file, "file");
        kotlin.jvm.internal.o.h(readerAction, "readerAction");
        J jC = AbstractC2732b.c(source(file));
        T t6 = null;
        try {
            Object objInvoke = readerAction.invoke(jC);
            try {
                jC.close();
            } catch (Throwable 
            /*  JADX ERROR: Method code generation error
                java.lang.NullPointerException: Cannot invoke "jadx.core.dex.instructions.args.SSAVar.getCodeVar()" because "ssaVar" is null
                	at jadx.core.codegen.RegionGen.makeCatchBlock(RegionGen.java:372)
                	at jadx.core.codegen.RegionGen.makeTryCatch(RegionGen.java:335)
                	at jadx.core.dex.regions.TryCatchRegion.generate(TryCatchRegion.java:85)
                	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                	at jadx.core.dex.regions.Region.generate(Region.java:35)
                	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                	at jadx.core.codegen.RegionGen.makeRegionIndent(RegionGen.java:83)
                	at jadx.core.codegen.RegionGen.makeTryCatch(RegionGen.java:320)
                	at jadx.core.dex.regions.TryCatchRegion.generate(TryCatchRegion.java:85)
                	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                	at jadx.core.dex.regions.Region.generate(Region.java:35)
                	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                	at jadx.core.codegen.MethodGen.addRegionInsns(MethodGen.java:305)
                	at jadx.core.codegen.MethodGen.addInstructions(MethodGen.java:284)
                	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:412)
                	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:337)
                	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:303)
                	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
                	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
                	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:261)
                */
            /*
                this = this;
                java.lang.String r0 = "file"
                kotlin.jvm.internal.o.h(r3, r0)
                java.lang.String r0 = "readerAction"
                kotlin.jvm.internal.o.h(r4, r0)
                p5.P r3 = r2.source(r3)
                p5.J r3 = p5.AbstractC2732b.c(r3)
                r0 = 0
                java.lang.Object r4 = r4.invoke(r3)     // Catch: java.lang.Throwable -> L20
                r3.close()     // Catch: java.lang.Throwable -> L1b
                goto L1c
            L1b:
                r0 = move-exception
            L1c:
                r1 = r0
                r0 = r4
                r4 = r1
                goto L29
            L20:
                r4 = move-exception
                r3.close()     // Catch: java.lang.Throwable -> L25
                goto L29
            L25:
                r3 = move-exception
                n2.AbstractC2613d.b(r4, r3)
            L29:
                if (r4 != 0) goto L2c
                return r0
            L2c:
                throw r4
            */
            throw new UnsupportedOperationException("Method not decompiled: p5.AbstractC2749t.m1213read(p5.G, J4.c):java.lang.Object");
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r5v0, types: [J4.c, java.lang.Object] */
        /* JADX WARN: Type inference failed for: r5v2, types: [java.lang.Throwable] */
        /* JADX WARN: Type inference failed for: r5v4 */
        /* JADX WARN: Type inference failed for: r5v5 */
        /* JADX WARN: Type inference failed for: r5v6 */
        /* JADX INFO: renamed from: -write, reason: not valid java name */
        public final <T> T m1214write(G file, boolean z6, J4.c writerAction) {
            ?? r5;
            kotlin.jvm.internal.o.h(file, "file");
            kotlin.jvm.internal.o.h(writerAction, "writerAction");
            I iB = AbstractC2732b.b(sink(file, z6));
            T t6 = null;
            try {
                Object objInvoke = writerAction.invoke(iB);
                try {
                    iB.close();
                } catch (Throwable 
                /*  JADX ERROR: Method code generation error
                    java.lang.NullPointerException: Cannot invoke "jadx.core.dex.instructions.args.SSAVar.getCodeVar()" because "ssaVar" is null
                    	at jadx.core.codegen.RegionGen.makeCatchBlock(RegionGen.java:372)
                    	at jadx.core.codegen.RegionGen.makeTryCatch(RegionGen.java:335)
                    	at jadx.core.dex.regions.TryCatchRegion.generate(TryCatchRegion.java:85)
                    	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                    	at jadx.core.dex.regions.Region.generate(Region.java:35)
                    	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                    	at jadx.core.codegen.RegionGen.makeRegionIndent(RegionGen.java:83)
                    	at jadx.core.codegen.RegionGen.makeTryCatch(RegionGen.java:320)
                    	at jadx.core.dex.regions.TryCatchRegion.generate(TryCatchRegion.java:85)
                    	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                    	at jadx.core.dex.regions.Region.generate(Region.java:35)
                    	at jadx.core.codegen.RegionGen.makeRegion(RegionGen.java:66)
                    	at jadx.core.codegen.MethodGen.addRegionInsns(MethodGen.java:305)
                    	at jadx.core.codegen.MethodGen.addInstructions(MethodGen.java:284)
                    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:412)
                    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:337)
                    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:303)
                    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
                    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
                    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:261)
                    */
                /*
                    this = this;
                    java.lang.String r0 = "file"
                    kotlin.jvm.internal.o.h(r3, r0)
                    java.lang.String r0 = "writerAction"
                    kotlin.jvm.internal.o.h(r5, r0)
                    p5.N r3 = r2.sink(r3, r4)
                    p5.I r3 = p5.AbstractC2732b.b(r3)
                    r4 = 0
                    java.lang.Object r5 = r5.invoke(r3)     // Catch: java.lang.Throwable -> L20
                    r3.close()     // Catch: java.lang.Throwable -> L1b
                    goto L1c
                L1b:
                    r4 = move-exception
                L1c:
                    r1 = r5
                    r5 = r4
                    r4 = r1
                    goto L29
                L20:
                    r5 = move-exception
                    r3.close()     // Catch: java.lang.Throwable -> L25
                    goto L29
                L25:
                    r3 = move-exception
                    n2.AbstractC2613d.b(r5, r3)
                L29:
                    if (r5 != 0) goto L2c
                    return r4
                L2c:
                    throw r5
                */
                throw new UnsupportedOperationException("Method not decompiled: p5.AbstractC2749t.m1214write(p5.G, boolean, J4.c):java.lang.Object");
            }

            public final N appendingSink(G file) {
                kotlin.jvm.internal.o.h(file, "file");
                return appendingSink(file, false);
            }

            public abstract N appendingSink(G g6, boolean z6);

            public abstract void atomicMove(G g6, G g7);

            public abstract G canonicalize(G g6);

            public void copy(G source, G target) throws Throwable {
                Throwable th;
                Long lValueOf;
                kotlin.jvm.internal.o.h(source, "source");
                kotlin.jvm.internal.o.h(target, "target");
                P pSource = source(source);
                Throwable th2 = null;
                try {
                    I iB = AbstractC2732b.b(sink$default(this, target, false, 2, null));
                    try {
                        lValueOf = Long.valueOf(iB.q(pSource));
                        try {
                            iB.close();
                            th = null;
                        } catch (Throwable th3) {
                            th = th3;
                        }
                    } catch (Throwable th4) {
                        try {
                            iB.close();
                        } catch (Throwable th5) {
                            AbstractC2613d.b(th4, th5);
                        }
                        th = th4;
                        lValueOf = null;
                    }
                } catch (Throwable th6) {
                    th2 = th6;
                    if (pSource != null) {
                        try {
                            pSource.close();
                        } catch (Throwable th7) {
                            AbstractC2613d.b(th2, th7);
                        }
                    }
                }
                if (th != null) {
                    throw th;
                }
                lValueOf.getClass();
                if (pSource != null) {
                    try {
                        pSource.close();
                    } catch (Throwable th8) {
                        th2 = th8;
                    }
                }
                if (th2 != null) {
                    throw th2;
                }
            }

            public final void createDirectories(G dir, boolean z6) throws IOException {
                kotlin.jvm.internal.o.h(dir, "dir");
                C3249o c3249o = new C3249o();
                for (G gC = dir; gC != null && !exists(gC); gC = gC.c()) {
                    c3249o.addFirst(gC);
                }
                if (z6 && c3249o.isEmpty()) {
                    throw new IOException(dir + " already exists.");
                }
                Iterator<E> it = c3249o.iterator();
                while (it.hasNext()) {
                    createDirectory$default(this, (G) it.next(), false, 2, null);
                }
            }

            public final void createDirectory(G dir) {
                kotlin.jvm.internal.o.h(dir, "dir");
                createDirectory(dir, false);
            }

            public abstract void createDirectory(G g6, boolean z6);

            public abstract void createSymlink(G g6, G g7);

            public final void delete(G path) {
                kotlin.jvm.internal.o.h(path, "path");
                delete(path, false);
            }

            public abstract void delete(G g6, boolean z6);

            public void deleteRecursively(G fileOrDirectory, boolean z6) {
                kotlin.jvm.internal.o.h(fileOrDirectory, "fileOrDirectory");
                R4.l lVarL = A4.g.L(new q5.d(this, fileOrDirectory, null));
                while (lVarL.hasNext()) {
                    delete((G) lVarL.next(), z6 && !lVarL.hasNext());
                }
            }

            public final boolean exists(G path) {
                kotlin.jvm.internal.o.h(path, "path");
                return metadataOrNull(path) != null;
            }

            public abstract List list(G g6);

            public abstract List listOrNull(G g6);

            public final R4.k listRecursively(G dir) {
                kotlin.jvm.internal.o.h(dir, "dir");
                return listRecursively(dir, false);
            }

            public final r metadata(G path) throws FileNotFoundException {
                kotlin.jvm.internal.o.h(path, "path");
                r rVarMetadataOrNull = metadataOrNull(path);
                if (rVarMetadataOrNull != null) {
                    return rVarMetadataOrNull;
                }
                throw new FileNotFoundException(com.google.android.recaptcha.internal.a.p(path, "no such file: "));
            }

            public abstract r metadataOrNull(G g6);

            public abstract AbstractC2747q openReadOnly(G g6);

            public final AbstractC2747q openReadWrite(G file) {
                kotlin.jvm.internal.o.h(file, "file");
                return openReadWrite(file, false, false);
            }

            public abstract AbstractC2747q openReadWrite(G g6, boolean z6, boolean z7);

            public final N sink(G file) {
                kotlin.jvm.internal.o.h(file, "file");
                return sink(file, false);
            }

            public abstract N sink(G g6, boolean z6);

            public abstract P source(G g6);

            public R4.k listRecursively(G dir, boolean z6) {
                kotlin.jvm.internal.o.h(dir, "dir");
                return new H4.f(new q5.e(dir, this, z6, null));
            }

            public final void deleteRecursively(G fileOrDirectory) {
                kotlin.jvm.internal.o.h(fileOrDirectory, "fileOrDirectory");
                deleteRecursively(fileOrDirectory, false);
            }

            public final void createDirectories(G dir) throws IOException {
                kotlin.jvm.internal.o.h(dir, "dir");
                createDirectories(dir, false);
            }

            @Override // java.io.Closeable, java.lang.AutoCloseable
            public void close() {
            }
        }
