package okhttp3.internal.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Logger;
import kotlin.jvm.internal.o;
import p5.AbstractC2732b;
import p5.C2734d;
import p5.C2735e;
import p5.E;

/* JADX INFO: loaded from: classes3.dex */
public interface FileSystem {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final FileSystem f22595a;

    public static final class Companion {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int f22596a = 0;

        public static final class SystemFileSystem implements FileSystem {
            @Override // okhttp3.internal.io.FileSystem
            public final C2735e a(File file) {
                o.h(file, "file");
                return AbstractC2732b.j(file);
            }

            @Override // okhttp3.internal.io.FileSystem
            public final C2734d b(File file) {
                o.h(file, "file");
                try {
                    Logger logger = E.f23044a;
                    return AbstractC2732b.h(new FileOutputStream(file, false));
                } catch (FileNotFoundException unused) {
                    file.getParentFile().mkdirs();
                    Logger logger2 = E.f23044a;
                    return AbstractC2732b.h(new FileOutputStream(file, false));
                }
            }

            @Override // okhttp3.internal.io.FileSystem
            public final void c(File file) throws IOException {
                File[] fileArrListFiles = file.listFiles();
                if (fileArrListFiles == null) {
                    throw new IOException("not a readable directory: " + file);
                }
                for (File file2 : fileArrListFiles) {
                    if (file2.isDirectory()) {
                        c(file2);
                    }
                    if (!file2.delete()) {
                        throw new IOException("failed to delete " + file2);
                    }
                }
            }

            @Override // okhttp3.internal.io.FileSystem
            public final boolean d(File file) {
                o.h(file, "file");
                return file.exists();
            }

            @Override // okhttp3.internal.io.FileSystem
            public final void e(File from, File to) throws IOException {
                o.h(from, "from");
                o.h(to, "to");
                f(to);
                if (from.renameTo(to)) {
                    return;
                }
                throw new IOException("failed to rename " + from + " to " + to);
            }

            @Override // okhttp3.internal.io.FileSystem
            public final void f(File file) throws IOException {
                o.h(file, "file");
                if (file.delete() || !file.exists()) {
                    return;
                }
                throw new IOException("failed to delete " + file);
            }

            @Override // okhttp3.internal.io.FileSystem
            public final C2734d g(File file) {
                o.h(file, "file");
                try {
                    Logger logger = E.f23044a;
                    return AbstractC2732b.h(new FileOutputStream(file, true));
                } catch (FileNotFoundException unused) {
                    file.getParentFile().mkdirs();
                    Logger logger2 = E.f23044a;
                    return AbstractC2732b.h(new FileOutputStream(file, true));
                }
            }

            @Override // okhttp3.internal.io.FileSystem
            public final long h(File file) {
                o.h(file, "file");
                return file.length();
            }

            public final String toString() {
                return "FileSystem.SYSTEM";
            }
        }

        static {
            new Companion();
        }

        private Companion() {
        }
    }

    static {
        int i6 = Companion.f22596a;
        f22595a = new Companion.SystemFileSystem();
    }

    C2735e a(File file);

    C2734d b(File file);

    void c(File file);

    boolean d(File file);

    void e(File file, File file2);

    void f(File file);

    C2734d g(File file);

    long h(File file);
}
