package okio;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0010\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J'\u0010\t\u001a\n\u0012\u0004\u0012\u00020\u0004\u0018\u00010\b2\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\t\u0010\nJ\u0013\u0010\f\u001a\u00020\u000b*\u00020\u0004H\u0002¢\u0006\u0004\b\f\u0010\rJ\u0013\u0010\u000e\u001a\u00020\u000b*\u00020\u0004H\u0002¢\u0006\u0004\b\u000e\u0010\rJ\u0019\u0010\u0011\u001a\u0004\u0018\u00010\u00102\u0006\u0010\u000f\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0011\u0010\u0012J\u001d\u0010\u0013\u001a\b\u0012\u0004\u0012\u00020\u00040\b2\u0006\u0010\u0005\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0013\u0010\u0014J\u001f\u0010\u0015\u001a\n\u0012\u0004\u0012\u00020\u0004\u0018\u00010\b2\u0006\u0010\u0005\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0015\u0010\u0014J\u0017\u0010\u0018\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0018\u0010\u0019J'\u0010\u001c\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u00042\u0006\u0010\u001a\u001a\u00020\u00062\u0006\u0010\u001b\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\u001c\u0010\u001dJ\u0017\u0010\u001f\u001a\u00020\u001e2\u0006\u0010\u0016\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u001f\u0010 J\u001f\u0010\"\u001a\u00020!2\u0006\u0010\u0016\u001a\u00020\u00042\u0006\u0010\u001a\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\"\u0010#J\u001f\u0010$\u001a\u00020!2\u0006\u0010\u0016\u001a\u00020\u00042\u0006\u0010\u001b\u001a\u00020\u0006H\u0016¢\u0006\u0004\b$\u0010#J\u001f\u0010%\u001a\u00020\u000b2\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u001a\u001a\u00020\u0006H\u0016¢\u0006\u0004\b%\u0010&J\u001f\u0010)\u001a\u00020\u000b2\u0006\u0010'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020\u0004H\u0016¢\u0006\u0004\b)\u0010*J\u001f\u0010+\u001a\u00020\u000b2\u0006\u0010\u000f\u001a\u00020\u00042\u0006\u0010\u001b\u001a\u00020\u0006H\u0016¢\u0006\u0004\b+\u0010&J\u000f\u0010-\u001a\u00020,H\u0016¢\u0006\u0004\b-\u0010.¨\u0006/"}, d2 = {"Lokio/JvmSystemFileSystem;", "Lokio/FileSystem;", "<init>", "()V", "Lokio/Path;", "dir", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "throwOnFailure", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "u", "(Lokio/Path;Z)Ljava/util/List;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "w", "(Lokio/Path;)V", "v", "path", "Lokio/FileMetadata;", "n", "(Lokio/Path;)Lokio/FileMetadata;", "k", "(Lokio/Path;)Ljava/util/List;", "l", "file", "Lokio/FileHandle;", "o", "(Lokio/Path;)Lokio/FileHandle;", "mustCreate", "mustExist", "q", "(Lokio/Path;ZZ)Lokio/FileHandle;", "Lokio/Source;", "t", "(Lokio/Path;)Lokio/Source;", "Lokio/Sink;", "s", "(Lokio/Path;Z)Lokio/Sink;", "b", "g", "(Lokio/Path;Z)V", "source", "target", "c", "(Lokio/Path;Lokio/Path;)V", "i", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "toString", "()Ljava/lang/String;", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public class JvmSystemFileSystem extends okio.FileSystem {
    private final java.util.List u(okio.Path dir, boolean throwOnFailure) throws java.io.IOException {
        java.io.File file = dir.toFile();
        java.lang.String[] list = file.list();
        if (list != null) {
            java.util.ArrayList arrayList = new java.util.ArrayList();
            for (java.lang.String str : list) {
                kotlin.jvm.internal.Intrinsics.i(str);
                arrayList.add(dir.j(str));
            }
            kotlin.collections.CollectionsKt.C(arrayList);
            return arrayList;
        }
        if (!throwOnFailure) {
            return null;
        }
        if (file.exists()) {
            throw new java.io.IOException("failed to list " + dir);
        }
        throw new java.io.FileNotFoundException("no such file: " + dir);
    }

    private final void v(okio.Path path) throws java.io.IOException {
        if (j(path)) {
            throw new java.io.IOException(path + " already exists.");
        }
    }

    private final void w(okio.Path path) throws java.io.IOException {
        if (j(path)) {
            return;
        }
        throw new java.io.IOException(path + " doesn't exist.");
    }

    @Override // okio.FileSystem
    public okio.Sink b(okio.Path file, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        if (mustExist) {
            w(file);
        }
        return okio.Okio.f(file.toFile(), true);
    }

    @Override // okio.FileSystem
    public void c(okio.Path source, okio.Path target) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        kotlin.jvm.internal.Intrinsics.l(target, "target");
        if (source.toFile().renameTo(target.toFile())) {
            return;
        }
        throw new java.io.IOException("failed to move " + source + " to " + target);
    }

    @Override // okio.FileSystem
    public void g(okio.Path dir, boolean mustCreate) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        if (dir.toFile().mkdir()) {
            return;
        }
        okio.FileMetadata fileMetadataN = n(dir);
        if (fileMetadataN == null || !fileMetadataN.getIsDirectory()) {
            throw new java.io.IOException("failed to create directory: " + dir);
        }
        if (mustCreate) {
            throw new java.io.IOException(dir + " already exists.");
        }
    }

    @Override // okio.FileSystem
    public void i(okio.Path path, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(path, "path");
        if (java.lang.Thread.interrupted()) {
            throw new java.io.InterruptedIOException("interrupted");
        }
        java.io.File file = path.toFile();
        if (file.delete()) {
            return;
        }
        if (file.exists()) {
            throw new java.io.IOException("failed to delete " + path);
        }
        if (mustExist) {
            throw new java.io.FileNotFoundException("no such file: " + path);
        }
    }

    @Override // okio.FileSystem
    public java.util.List k(okio.Path dir) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        java.util.List listU = u(dir, true);
        kotlin.jvm.internal.Intrinsics.i(listU);
        return listU;
    }

    @Override // okio.FileSystem
    public java.util.List l(okio.Path dir) {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        return u(dir, false);
    }

    @Override // okio.FileSystem
    public okio.FileMetadata n(okio.Path path) {
        kotlin.jvm.internal.Intrinsics.l(path, "path");
        java.io.File file = path.toFile();
        boolean zIsFile = file.isFile();
        boolean zIsDirectory = file.isDirectory();
        long jLastModified = file.lastModified();
        long length = file.length();
        if (zIsFile || zIsDirectory || jLastModified != 0 || length != 0 || file.exists()) {
            return new okio.FileMetadata(zIsFile, zIsDirectory, null, java.lang.Long.valueOf(length), null, java.lang.Long.valueOf(jLastModified), null, null, 128, null);
        }
        return null;
    }

    @Override // okio.FileSystem
    public okio.FileHandle o(okio.Path file) {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        return new okio.JvmFileHandle(false, new java.io.RandomAccessFile(file.toFile(), "r"));
    }

    @Override // okio.FileSystem
    public okio.FileHandle q(okio.Path file, boolean mustCreate, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        if (mustCreate && mustExist) {
            throw new java.lang.IllegalArgumentException("Cannot require mustCreate and mustExist at the same time.");
        }
        if (mustCreate) {
            v(file);
        }
        if (mustExist) {
            w(file);
        }
        return new okio.JvmFileHandle(true, new java.io.RandomAccessFile(file.toFile(), "rw"));
    }

    @Override // okio.FileSystem
    public okio.Sink s(okio.Path file, boolean mustCreate) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        if (mustCreate) {
            v(file);
        }
        return okio.Okio__JvmOkioKt.g(file.toFile(), false, 1, null);
    }

    @Override // okio.FileSystem
    public okio.Source t(okio.Path file) {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        return okio.Okio.j(file.toFile());
    }

    public java.lang.String toString() {
        return "JvmSystemFileSystem";
    }
}
