/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  javax.microedition.io.Connection
 *  javax.microedition.io.Connector
 *  javax.microedition.io.file.FileConnection
 */
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.io.Connection;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;

public final class pj
extends jp {
    private final ct x;
    private final String y;
    public final pj n;
    private oe A;
    private int w = 0;
    private Vector z;
    public long o;

    public final oe e() {
        return this.A;
    }

    public static void a(Connection connection) {
        try {
            if (connection != null) {
                connection.close();
            }
            return;
        }
        catch (IOException iOException) {
            return;
        }
    }

    public final synchronized void n() {
        block9: {
            block10: {
                block11: {
                    FileConnection fileConnection;
                    block8: {
                        if (this.w > 1) break block9;
                        this.w = 1;
                        this.t();
                        if (this.f()) break block10;
                        fileConnection = null;
                        String string = "file:///" + this.k();
                        try {
                            try {
                                if (this.y.lastIndexOf(46) != -1 && this.x.a(this.y)) {
                                    fileConnection = (FileConnection)Connector.open((String)string, (int)1);
                                    this.o = fileConnection.lastModified();
                                    this.A = new oe(lh.k().g().a(ar.a(fileConnection.openDataInputStream()), this.x.c()));
                                }
                                this.w = 2;
                            }
                            catch (OutOfMemoryError outOfMemoryError) {
                                this.a(this.j());
                                me.a("FileBrowser", outOfMemoryError);
                                this.w = 3;
                                break block8;
                            }
                            catch (IOException iOException) {
                                this.a(this.j());
                                me.a("FileBrowser", iOException);
                                this.w = 3;
                                pj.a(fileConnection);
                            }
                        }
                        catch (Throwable throwable) {
                            pj.a(fileConnection);
                            throw throwable;
                        }
                        pj.a(fileConnection);
                        break block11;
                    }
                    pj.a(fileConnection);
                }
                this.t();
                return;
            }
            try {
                this.m();
                this.t();
                return;
            }
            catch (IOException iOException) {
                me.a("FileBrowser", iOException);
                this.w = 3;
            }
        }
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public final synchronized Vector m() {
        FileConnection fileConnection2;
        if (this.z != null) return this.z;
        FileConnection fileConnection = null;
        this.z = new Vector();
        try {
            fileConnection = fileConnection2 = (FileConnection)Connector.open((String)("file:///" + this.k()), (int)1);
            Enumeration enumeration = fileConnection2.list();
            while (enumeration.hasMoreElements()) {
                String string = (String)enumeration.nextElement();
                if (!this.x.a(string)) continue;
                String string2 = string.indexOf(".") == -1 ? string : "";
                this.z.addElement(new pj(this.r, this.x, this, string, string2, this.b));
            }
        }
        catch (Throwable throwable) {
            pj.a(fileConnection);
            throw throwable;
        }
        pj.a((Connection)fileConnection2);
        this.w = 2;
        this.t();
        return this.z;
    }

    public final byte[] l() {
        FileConnection fileConnection;
        block4: {
            FileConnection fileConnection2;
            block5: {
                byte[] byArray;
                fileConnection2 = null;
                try {
                    try {
                        fileConnection2 = fileConnection = (FileConnection)Connector.open((String)("file:///" + this.k()), (int)1);
                        if (!fileConnection.exists()) break block4;
                        byArray = ar.a(fileConnection.openDataInputStream());
                    }
                    catch (IOException iOException) {
                        me.a("FileBrowser", iOException);
                        break block5;
                    }
                }
                catch (Throwable throwable) {
                    pj.a(fileConnection2);
                    throw throwable;
                }
                pj.a((Connection)fileConnection);
                return byArray;
            }
            pj.a(fileConnection2);
            return null;
        }
        pj.a((Connection)fileConnection);
        return null;
    }

    public final String k() {
        if (this.n != null && this.n.y != null) {
            return this.n.k() + this.y;
        }
        return this.y;
    }

    public pj(int n, ct ct2, pj pj2, String string, String string2, w w2) {
        super(0, 0, n, 4, 0, w2, string2, false, ps.a().k, 0, 0, null, null);
        this.y = string;
        this.x = ct2;
        this.n = pj2;
        if (!this.f()) {
            this.m(ct2.c() + pj.d() * 2);
            this.A = new oe(ct2.h().a(ct2.c(), ct2.c()));
            return;
        }
        this.A = new oe(null);
    }

    public final boolean f() {
        return this.y == null || this.y.endsWith("/");
    }

    public final String j() {
        if (this.y != null) {
            return this.y;
        }
        return "";
    }
}

