导航菜单

页面标题

页面副标题

安博 v1.0.0 - a.java 源代码

正在查看: 安博 v1.0.0 应用的 a.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package h0;

import io.dcloud.common.util.JSUtil;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

public final class a implements Closeable {
    static final Pattern o = Pattern.compile("[a-z0-9_-]{1,64}");

    private static final OutputStream f1p = new b();
    private final File a;
    private final File b;
    private final File c;
    private final File d;

    private final int f2e;

    private long f3f;

    private final int f4g;
    private Writer i;

    private int f6k;

    private long f5h = 0;
    private final LinkedHashMap j = new LinkedHashMap(0, 0.75f, true);
    private long l = 0;
    final ThreadPoolExecutor m = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue());
    private final Callable n = new CallableC0002a();

    class CallableC0002a implements Callable {
        CallableC0002a() {
        }

        @Override
        public Void call() {
            synchronized (a.this) {
                if (a.this.i == null) {
                    return null;
                }
                a.this.h();
                if (a.this.d()) {
                    a.this.g();
                    a.this.f6k = 0;
                }
                return null;
            }
        }
    }

    class b extends OutputStream {
        b() {
        }

        @Override
        public void write(int i) {
        }
    }

    public final class c {
        private final d a;
        private final boolean[] b;
        private boolean c;
        private boolean d;

        private class C0003a extends FilterOutputStream {
            C0003a(c cVar, OutputStream outputStream, CallableC0002a callableC0002a) {
                this(outputStream);
            }

            @Override
            public void close() {
                try {
                    ((FilterOutputStream) this).out.close();
                } catch (IOException unused) {
                    c.this.c = true;
                }
            }

            @Override
            public void flush() {
                try {
                    ((FilterOutputStream) this).out.flush();
                } catch (IOException unused) {
                    c.this.c = true;
                }
            }

            @Override
            public void write(int i) {
                try {
                    ((FilterOutputStream) this).out.write(i);
                } catch (IOException unused) {
                    c.this.c = true;
                }
            }

            private C0003a(OutputStream outputStream) {
                super(outputStream);
            }

            @Override
            public void write(byte[] bArr, int i, int i2) {
                try {
                    ((FilterOutputStream) this).out.write(bArr, i, i2);
                } catch (IOException unused) {
                    c.this.c = true;
                }
            }
        }

        c(a aVar, d dVar, CallableC0002a callableC0002a) {
            this(dVar);
        }

        private c(d dVar) {
            this.a = dVar;
            this.b = dVar.c ? null : new boolean[a.this.f4g];
        }

        public void b() {
            if (this.c) {
                a.this.a(this, false);
                a.this.d(this.a.a);
            } else {
                a.this.a(this, true);
            }
            this.d = true;
        }

        public OutputStream a(int i) {
            FileOutputStream fileOutputStream;
            C0003a c0003a;
            synchronized (a.this) {
                if (this.a.d == this) {
                    if (!this.a.c) {
                        this.b[i] = true;
                    }
                    File b = this.a.b(i);
                    try {
                        fileOutputStream = new FileOutputStream(b);
                    } catch (FileNotFoundException unused) {
                        a.this.a.mkdirs();
                        try {
                            fileOutputStream = new FileOutputStream(b);
                        } catch (FileNotFoundException unused2) {
                            return a.f1p;
                        }
                    }
                    c0003a = new C0003a(this, fileOutputStream, null);
                } else {
                    throw new IllegalStateException();
                }
            }
            return c0003a;
        }

        public void a() {
            a.this.a(this, false);
        }
    }

    private final class d {
        private final String a;
        private final long[] b;
        private boolean c;
        private c d;

        private long f8e;

        d(a aVar, String str, CallableC0002a callableC0002a) {
            this(str);
        }

        private d(String str) {
            this.a = str;
            this.b = new long[a.this.f4g];
        }

        public void b(String[] strArr) {
            if (strArr.length != a.this.f4g) {
                throw a(strArr);
            }
            for (int i = 0; i < strArr.length; i++) {
                try {
                    this.b[i] = Long.parseLong(strArr[i]);
                } catch (NumberFormatException unused) {
                    throw a(strArr);
                }
            }
        }

        public String a() {
            StringBuilder sb = new StringBuilder();
            for (long j : this.b) {
                sb.append(' ');
                sb.append(j);
            }
            return sb.toString();
        }

        private IOException a(String[] strArr) {
            throw new IOException("unexpected journal line: " + Arrays.toString(strArr));
        }

        public File a(int i) {
            return new File(a.this.a, this.a + "." + i);
        }

        public File b(int i) {
            return new File(a.this.a, this.a + "." + i + ".tmp");
        }
    }

    public final class e implements Closeable {
        private final String a;
        private final long b;
        private final InputStream[] c;
        private final long[] d;

        e(a aVar, String str, long j, InputStream[] inputStreamArr, long[] jArr, CallableC0002a callableC0002a) {
            this(str, j, inputStreamArr, jArr);
        }

        public InputStream a(int i) {
            return this.c[i];
        }

        public String b(int i) {
            return a.b(a(i));
        }

        @Override
        public void close() {
            for (InputStream inputStream : this.c) {
                h0.c.a(inputStream);
            }
        }

        private e(String str, long j, InputStream[] inputStreamArr, long[] jArr) {
            this.a = str;
            this.b = j;
            this.c = inputStreamArr;
            this.d = jArr;
        }
    }

    private a(File file, int i, int i2, long j) {
        this.a = file;
        this.f2e = i;
        this.b = new File(file, "journal");
        this.c = new File(file, "journal.tmp");
        this.d = new File(file, "journal.bkp");
        this.f4g = i2;
        this.f3f = j;
    }

    public synchronized void g() {
        Writer writer = this.i;
        if (writer != null) {
            writer.close();
        }
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.c), h0.c.a));
        try {
            bufferedWriter.write("libcore.io.DiskLruCache");
            bufferedWriter.write("\n");
            bufferedWriter.write("1");
            bufferedWriter.write("\n");
            bufferedWriter.write(Integer.toString(this.f2e));
            bufferedWriter.write("\n");
            bufferedWriter.write(Integer.toString(this.f4g));
            bufferedWriter.write("\n");
            bufferedWriter.write("\n");
            for (d dVar : this.j.values()) {
                if (dVar.d != null) {
                    bufferedWriter.write("DIRTY " + dVar.a + '\n');
                } else {
                    bufferedWriter.write("CLEAN " + dVar.a + dVar.a() + '\n');
                }
            }
            bufferedWriter.close();
            if (this.b.exists()) {
                a(this.b, this.d, true);
            }
            a(this.c, this.b, false);
            this.d.delete();
            this.i = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.b, true), h0.c.a));
        } catch (Throwable th) {
            bufferedWriter.close();
            throw th;
        }
    }

    public void h() {
        while (this.f5h > this.f3f) {
            d((String) ((Map.Entry) this.j.entrySet().iterator().next()).getKey());
        }
    }

    @Override
    public synchronized void close() {
        if (this.i == null) {
            return;
        }
        Iterator it = new ArrayList(this.j.values()).iterator();
        while (it.hasNext()) {
            d dVar = (d) it.next();
            if (dVar.d != null) {
                dVar.d.a();
            }
        }
        h();
        this.i.close();
        this.i = null;
    }

    public synchronized void flush() {
        b();
        h();
        this.i.flush();
    }

    private void c(String str) {
        String substring;
        int indexOf = str.indexOf(32);
        if (indexOf == -1) {
            throw new IOException("unexpected journal line: " + str);
        }
        int i = indexOf + 1;
        int indexOf2 = str.indexOf(32, i);
        if (indexOf2 == -1) {
            substring = str.substring(i);
            if (indexOf == 6 && str.startsWith("REMOVE")) {
                this.j.remove(substring);
                return;
            }
        } else {
            substring = str.substring(i, indexOf2);
        }
        d dVar = (d) this.j.get(substring);
        CallableC0002a callableC0002a = null;
        if (dVar == null) {
            dVar = new d(this, substring, callableC0002a);
            this.j.put(substring, dVar);
        }
        if (indexOf2 != -1 && indexOf == 5 && str.startsWith("CLEAN")) {
            String[] split = str.substring(indexOf2 + 1).split(" ");
            dVar.c = true;
            dVar.d = null;
            dVar.b(split);
            return;
        }
        if (indexOf2 == -1 && indexOf == 5 && str.startsWith("DIRTY")) {
            dVar.d = new c(this, dVar, callableC0002a);
        } else {
            if (indexOf2 == -1 && indexOf == 4 && str.startsWith("READ")) {
                return;
            }
            throw new IOException("unexpected journal line: " + str);
        }
    }

    public boolean d() {
        int i = this.f6k;
        return i >= 2000 && i >= this.j.size();
    }

    private void e() {
        a(this.c);
        Iterator it = this.j.values().iterator();
        while (it.hasNext()) {
            d dVar = (d) it.next();
            int i = 0;
            if (dVar.d == null) {
                while (i < this.f4g) {
                    this.f5h += dVar.b[i];
                    i++;
                }
            } else {
                dVar.d = null;
                while (i < this.f4g) {
                    a(dVar.a(i));
                    a(dVar.b(i));
                    i++;
                }
                it.remove();
            }
        }
    }

    private void f() {
        h0.b bVar = new h0.b(new FileInputStream(this.b), h0.c.a);
        try {
            String b2 = bVar.b();
            String b3 = bVar.b();
            String b4 = bVar.b();
            String b5 = bVar.b();
            String b6 = bVar.b();
            if (!"libcore.io.DiskLruCache".equals(b2) || !"1".equals(b3) || !Integer.toString(this.f2e).equals(b4) || !Integer.toString(this.f4g).equals(b5) || !"".equals(b6)) {
                throw new IOException("unexpected journal header: [" + b2 + ", " + b3 + ", " + b5 + ", " + b6 + "]");
            }
            int i = 0;
            while (true) {
                try {
                    c(bVar.b());
                    i++;
                } catch (EOFException unused) {
                    this.f6k = i - this.j.size();
                    h0.c.a(bVar);
                    return;
                }
            }
        } catch (Throwable th) {
            h0.c.a(bVar);
            throw th;
        }
    }

    public synchronized e b(String str) {
        InputStream inputStream;
        b();
        e(str);
        d dVar = (d) this.j.get(str);
        if (dVar == null) {
            return null;
        }
        if (!dVar.c) {
            return null;
        }
        InputStream[] inputStreamArr = new InputStream[this.f4g];
        for (int i = 0; i < this.f4g; i++) {
            try {
                inputStreamArr[i] = new FileInputStream(dVar.a(i));
            } catch (FileNotFoundException unused) {
                for (int i2 = 0; i2 < this.f4g && (inputStream = inputStreamArr[i2]) != null; i2++) {
                    h0.c.a(inputStream);
                }
                return null;
            }
        }
        this.f6k++;
        this.i.append((CharSequence) ("READ " + str + '\n'));
        if (d()) {
            this.m.submit(this.n);
        }
        return new e(this, str, dVar.f8e, inputStreamArr, dVar.b, null);
    }

    public synchronized boolean d(String str) {
        b();
        e(str);
        d dVar = (d) this.j.get(str);
        if (dVar != null && dVar.d == null) {
            for (int i = 0; i < this.f4g; i++) {
                File a = dVar.a(i);
                if (a.exists() && !a.delete()) {
                    throw new IOException("failed to delete " + a);
                }
                this.f5h -= dVar.b[i];
                dVar.b[i] = 0;
            }
            this.f6k++;
            this.i.append((CharSequence) ("REMOVE " + str + '\n'));
            this.j.remove(str);
            if (d()) {
                this.m.submit(this.n);
            }
            return true;
        }
        return false;
    }

    public static a a(File file, int i, int i2, long j) {
        if (j <= 0) {
            throw new IllegalArgumentException("maxSize <= 0");
        }
        if (i2 > 0) {
            File file2 = new File(file, "journal.bkp");
            if (file2.exists()) {
                File file3 = new File(file, "journal");
                if (file3.exists()) {
                    file2.delete();
                } else {
                    a(file2, file3, false);
                }
            }
            a aVar = new a(file, i, i2, j);
            if (aVar.b.exists()) {
                try {
                    aVar.f();
                    aVar.e();
                    aVar.i = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(aVar.b, true), h0.c.a));
                    return aVar;
                } catch (IOException e2) {
                    System.out.println("DiskLruCache " + file + " is corrupt: " + e2.getMessage() + ", removing");
                    aVar.c();
                }
            }
            file.mkdirs();
            a aVar2 = new a(file, i, i2, j);
            aVar2.g();
            return aVar2;
        }
        throw new IllegalArgumentException("valueCount <= 0");
    }

    private void e(String str) {
        if (o.matcher(str).matches()) {
            return;
        }
        throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,64}: \"" + str + JSUtil.QUOTE);
    }

    public void c() {
        close();
        h0.c.a(this.a);
    }

    private void b() {
        if (this.i == null) {
            throw new IllegalStateException("cache is closed");
        }
    }

    public static String b(InputStream inputStream) {
        return h0.c.a((Reader) new InputStreamReader(inputStream, h0.c.b));
    }

    private static void a(File file) {
        if (file.exists() && !file.delete()) {
            throw new IOException();
        }
    }

    private static void a(File file, File file2, boolean z2) {
        if (z2) {
            a(file2);
        }
        if (!file.renameTo(file2)) {
            throw new IOException();
        }
    }

    public c a(String str) {
        return a(str, -1L);
    }

    private synchronized c a(String str, long j) {
        b();
        e(str);
        d dVar = (d) this.j.get(str);
        CallableC0002a callableC0002a = null;
        if (j != -1 && (dVar == null || dVar.f8e != j)) {
            return null;
        }
        if (dVar != null) {
            if (dVar.d != null) {
                return null;
            }
        } else {
            dVar = new d(this, str, callableC0002a);
            this.j.put(str, dVar);
        }
        c cVar = new c(this, dVar, callableC0002a);
        dVar.d = cVar;
        this.i.write("DIRTY " + str + '\n');
        this.i.flush();
        return cVar;
    }

    public synchronized void a(c cVar, boolean z2) {
        d dVar = cVar.a;
        if (dVar.d == cVar) {
            if (z2 && !dVar.c) {
                for (int i = 0; i < this.f4g; i++) {
                    if (cVar.b[i]) {
                        if (!dVar.b(i).exists()) {
                            cVar.a();
                            return;
                        }
                    } else {
                        cVar.a();
                        throw new IllegalStateException("Newly created entry didn't create value for index " + i);
                    }
                }
            }
            for (int i2 = 0; i2 < this.f4g; i2++) {
                File b2 = dVar.b(i2);
                if (z2) {
                    if (b2.exists()) {
                        File a = dVar.a(i2);
                        b2.renameTo(a);
                        long j = dVar.b[i2];
                        long length = a.length();
                        dVar.b[i2] = length;
                        this.f5h = (this.f5h - j) + length;
                    }
                } else {
                    a(b2);
                }
            }
            this.f6k++;
            dVar.d = null;
            if (!(dVar.c | z2)) {
                this.j.remove(dVar.a);
                this.i.write("REMOVE " + dVar.a + '\n');
            } else {
                dVar.c = true;
                this.i.write("CLEAN " + dVar.a + dVar.a() + '\n');
                if (z2) {
                    long j2 = this.l;
                    this.l = 1 + j2;
                    dVar.f8e = j2;
                }
            }
            this.i.flush();
            if (this.f5h > this.f3f || d()) {
                this.m.submit(this.n);
            }
            return;
        }
        throw new IllegalStateException();
    }
}