package e.r;

import com.seewo.vcommons.constants.Platform;
import e.m;
import e.s.b.p;
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public final class e implements e.v.b<File> {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final File f5984a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final f f5985b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final e.s.b.l<File, Boolean> f5986c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final e.s.b.l<File, m> f5987d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final p<File, IOException, m> f5988e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int f5989f;

    public static abstract class a extends c {
        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public a(File file) {
            super(file);
            e.s.c.k.e(file, "rootDir");
        }
    }

    public final class b extends e.o.a<File> {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final ArrayDeque<c> f5990d;

        public final class a extends a {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public boolean f5992b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            public File[] f5993c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            public int f5994d;

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public boolean f5995e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            public final /* synthetic */ b f5996f;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public a(b bVar, File file) {
                super(file);
                e.s.c.k.e(file, "rootDir");
                this.f5996f = bVar;
            }

            @Override // e.r.e.c
            public File a() {
                if (!this.f5995e && this.f5993c == null) {
                    e.s.b.l<File, Boolean> lVar = e.this.f5986c;
                    if (lVar != null && !lVar.e(this.f6002a).booleanValue()) {
                        return null;
                    }
                    File[] fileArrListFiles = this.f6002a.listFiles();
                    this.f5993c = fileArrListFiles;
                    if (fileArrListFiles == null) {
                        p<File, IOException, m> pVar = e.this.f5988e;
                        if (pVar != null) {
                            pVar.c(this.f6002a, new e.r.a(this.f6002a, null, "Cannot list files in a directory", 2));
                        }
                        this.f5995e = true;
                    }
                }
                File[] fileArr = this.f5993c;
                if (fileArr != null) {
                    int i2 = this.f5994d;
                    e.s.c.k.c(fileArr);
                    if (i2 < fileArr.length) {
                        File[] fileArr2 = this.f5993c;
                        e.s.c.k.c(fileArr2);
                        int i3 = this.f5994d;
                        this.f5994d = i3 + 1;
                        return fileArr2[i3];
                    }
                }
                if (!this.f5992b) {
                    this.f5992b = true;
                    return this.f6002a;
                }
                e.s.b.l<File, m> lVar2 = e.this.f5987d;
                if (lVar2 != null) {
                    lVar2.e(this.f6002a);
                }
                return null;
            }
        }

        /* JADX INFO: renamed from: e.r.e$b$b, reason: collision with other inner class name */
        public final class C0085b extends c {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public boolean f5997b;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C0085b(b bVar, File file) {
                super(file);
                e.s.c.k.e(file, "rootFile");
            }

            @Override // e.r.e.c
            public File a() {
                if (this.f5997b) {
                    return null;
                }
                this.f5997b = true;
                return this.f6002a;
            }
        }

        public final class c extends a {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public boolean f5998b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            public File[] f5999c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            public int f6000d;

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ b f6001e;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public c(b bVar, File file) {
                super(file);
                e.s.c.k.e(file, "rootDir");
                this.f6001e = bVar;
            }

            /* JADX WARN: Code restructure failed: missing block: B:30:0x0070, code lost:
            
                if (r0.length == 0) goto L31;
             */
            @Override // e.r.e.c
            /*
                Code decompiled incorrectly, please refer to instructions dump.
                To view partially-correct add '--show-bad-code' argument
            */
            public java.io.File a() {
                /*
                    r7 = this;
                    boolean r0 = r7.f5998b
                    r1 = 0
                    if (r0 != 0) goto L22
                    e.r.e$b r0 = r7.f6001e
                    e.r.e r0 = e.r.e.this
                    e.s.b.l<java.io.File, java.lang.Boolean> r0 = r0.f5986c
                    if (r0 == 0) goto L1c
                    java.io.File r2 = r7.f6002a
                    java.lang.Object r0 = r0.e(r2)
                    java.lang.Boolean r0 = (java.lang.Boolean) r0
                    boolean r0 = r0.booleanValue()
                    if (r0 != 0) goto L1c
                    return r1
                L1c:
                    r0 = 1
                    r7.f5998b = r0
                    java.io.File r0 = r7.f6002a
                    return r0
                L22:
                    java.io.File[] r0 = r7.f5999c
                    if (r0 == 0) goto L40
                    int r2 = r7.f6000d
                    e.s.c.k.c(r0)
                    int r0 = r0.length
                    if (r2 >= r0) goto L2f
                    goto L40
                L2f:
                    e.r.e$b r0 = r7.f6001e
                    e.r.e r0 = e.r.e.this
                    e.s.b.l<java.io.File, e.m> r0 = r0.f5987d
                    if (r0 == 0) goto L3f
                    java.io.File r2 = r7.f6002a
                    java.lang.Object r0 = r0.e(r2)
                    e.m r0 = (e.m) r0
                L3f:
                    return r1
                L40:
                    java.io.File[] r0 = r7.f5999c
                    if (r0 != 0) goto L83
                    java.io.File r0 = r7.f6002a
                    java.io.File[] r0 = r0.listFiles()
                    r7.f5999c = r0
                    if (r0 != 0) goto L68
                    e.r.e$b r0 = r7.f6001e
                    e.r.e r0 = e.r.e.this
                    e.s.b.p<java.io.File, java.io.IOException, e.m> r0 = r0.f5988e
                    if (r0 == 0) goto L68
                    java.io.File r2 = r7.f6002a
                    e.r.a r3 = new e.r.a
                    java.io.File r4 = r7.f6002a
                    r5 = 2
                    java.lang.String r6 = "Cannot list files in a directory"
                    r3.<init>(r4, r1, r6, r5)
                    java.lang.Object r0 = r0.c(r2, r3)
                    e.m r0 = (e.m) r0
                L68:
                    java.io.File[] r0 = r7.f5999c
                    if (r0 == 0) goto L72
                    e.s.c.k.c(r0)
                    int r0 = r0.length
                    if (r0 != 0) goto L83
                L72:
                    e.r.e$b r0 = r7.f6001e
                    e.r.e r0 = e.r.e.this
                    e.s.b.l<java.io.File, e.m> r0 = r0.f5987d
                    if (r0 == 0) goto L82
                    java.io.File r2 = r7.f6002a
                    java.lang.Object r0 = r0.e(r2)
                    e.m r0 = (e.m) r0
                L82:
                    return r1
                L83:
                    java.io.File[] r0 = r7.f5999c
                    e.s.c.k.c(r0)
                    int r1 = r7.f6000d
                    int r2 = r1 + 1
                    r7.f6000d = r2
                    r0 = r0[r1]
                    return r0
                */
                throw new UnsupportedOperationException("Method not decompiled: e.r.e.b.c.a():java.io.File");
            }
        }

        public b() {
            ArrayDeque<c> arrayDeque = new ArrayDeque<>();
            this.f5990d = arrayDeque;
            if (e.this.f5984a.isDirectory()) {
                arrayDeque.push(a(e.this.f5984a));
            } else if (e.this.f5984a.isFile()) {
                arrayDeque.push(new C0085b(this, e.this.f5984a));
            } else {
                this.f5959b = e.o.j.Done;
            }
        }

        public final a a(File file) {
            int iOrdinal = e.this.f5985b.ordinal();
            if (iOrdinal == 0) {
                return new c(this, file);
            }
            if (iOrdinal == 1) {
                return new a(this, file);
            }
            throw new e.d();
        }
    }

    public static abstract class c {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final File f6002a;

        public c(File file) {
            e.s.c.k.e(file, "root");
            this.f6002a = file;
        }

        public abstract File a();
    }

    public e(File file, f fVar) {
        e.s.c.k.e(file, "start");
        e.s.c.k.e(fVar, "direction");
        this.f5984a = file;
        this.f5985b = fVar;
        this.f5986c = null;
        this.f5987d = null;
        this.f5988e = null;
        this.f5989f = Platform.UNKNOWN;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public e(File file, f fVar, e.s.b.l<? super File, Boolean> lVar, e.s.b.l<? super File, m> lVar2, p<? super File, ? super IOException, m> pVar, int i2) {
        this.f5984a = file;
        this.f5985b = fVar;
        this.f5986c = lVar;
        this.f5987d = lVar2;
        this.f5988e = pVar;
        this.f5989f = i2;
    }

    @Override // e.v.b
    public Iterator<File> iterator() {
        return new b();
    }
}
