正在查看: 饼干视频 v4.1.0 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 饼干视频 v4.1.0 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.moqi.sdk.cache;
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.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 {
public static final String o = "journal";
public static final String p = "journal.tmp";
public static final String q = "journal.bkp";
public static final String r = "libcore.io.DiskLruCache";
public static final String s = "1";
public static final long t = -1;
private static final String w = "CLEAN";
private static final String x = "DIRTY";
private static final String y = "REMOVE";
private static final String z = "READ";
private final File a;
private final File b;
private final File c;
private final File d;
private final int e;
private long f;
private final int g;
private Writer i;
private int k;
public static final String u = "[a-z0-9_-]{1,120}";
public static final Pattern v = Pattern.compile(u);
private static final OutputStream A = new b();
private long h = 0;
private final LinkedHashMap<String, d> j = new LinkedHashMap<>(0, 0.75f, true);
private long l = 0;
public final ThreadPoolExecutor m = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue());
private final Callable<Void> n = new CallableC2403a();
public class CallableC2403a implements Callable<Void> {
public CallableC2403a() {
}
@Override
public Void call() throws Exception {
synchronized (a.this) {
if (a.this.i == null) {
return null;
}
a.this.j();
if (a.this.f()) {
a.this.i();
a.this.k = 0;
}
return null;
}
}
}
public class b extends OutputStream {
@Override
public void write(int i) throws IOException {
}
}
public final class c {
private final d a;
private final boolean[] b;
private boolean c;
private boolean d;
public class C2404a extends FilterOutputStream {
private C2404a(OutputStream outputStream) {
super(outputStream);
}
public C2404a(c cVar, OutputStream outputStream, CallableC2403a callableC2403a) {
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;
}
}
@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;
}
}
}
private c(d dVar) {
this.a = dVar;
this.b = dVar.c ? null : new boolean[a.this.g];
}
public c(a aVar, d dVar, CallableC2403a callableC2403a) {
this(dVar);
}
public String a(int i) throws IOException {
InputStream b = b(i);
if (b != null) {
return a.b(b);
}
return null;
}
public void a() throws IOException {
a.this.a(this, false);
}
public void a(int i, String str) throws IOException {
OutputStreamWriter outputStreamWriter = null;
try {
OutputStreamWriter outputStreamWriter2 = new OutputStreamWriter(c(i), com.moqi.sdk.cache.d.b);
try {
outputStreamWriter2.write(str);
com.moqi.sdk.cache.d.a(outputStreamWriter2);
} catch (Throwable th) {
th = th;
outputStreamWriter = outputStreamWriter2;
com.moqi.sdk.cache.d.a(outputStreamWriter);
throw th;
}
} catch (Throwable th2) {
th = th2;
}
}
public InputStream b(int i) throws IOException {
synchronized (a.this) {
if (this.a.d != this) {
throw new IllegalStateException();
}
if (!this.a.c) {
return null;
}
try {
return new FileInputStream(this.a.a(i));
} catch (FileNotFoundException unused) {
return null;
}
}
}
public void b() {
if (this.d) {
return;
}
try {
a();
} catch (IOException unused) {
}
}
public OutputStream c(int i) throws IOException {
FileOutputStream fileOutputStream;
C2404a c2404a;
if (i < 0 || i >= a.this.g) {
throw new IllegalArgumentException("Expected index " + i + " to be greater than 0 and less than the maximum value count of " + a.this.g);
}
synchronized (a.this) {
if (this.a.d != this) {
throw new IllegalStateException();
}
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.A;
}
}
c2404a = new C2404a(this, fileOutputStream, null);
}
return c2404a;
}
public void c() throws IOException {
if (this.c) {
a.this.a(this, false);
a.this.d(this.a.a);
} else {
a.this.a(this, true);
}
this.d = true;
}
}
public final class d {
private final String a;
private final long[] b;
private boolean c;
private c d;
private long e;
private d(String str) {
this.a = str;
this.b = new long[a.this.g];
}
public d(a aVar, String str, CallableC2403a callableC2403a) {
this(str);
}
private IOException a(String[] strArr) throws IOException {
throw new IOException("unexpected journal line: " + Arrays.toString(strArr));
}
public void b(String[] strArr) throws IOException {
if (strArr.length != a.this.g) {
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 File a(int i) {
return new File(a.this.a, this.a + "." + i);
}
public String a() throws IOException {
StringBuilder sb = new StringBuilder();
for (long j : this.b) {
sb.append(' ');
sb.append(j);
}
return sb.toString();
}
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;
private e(String str, long j, InputStream[] inputStreamArr, long[] jArr) {
this.a = str;
this.b = j;
this.c = inputStreamArr;
this.d = jArr;
}
public e(a aVar, String str, long j, InputStream[] inputStreamArr, long[] jArr, CallableC2403a callableC2403a) {
this(str, j, inputStreamArr, jArr);
}
public c a() throws IOException {
return a.this.a(this.a, this.b);
}
public InputStream a(int i) {
return this.c[i];
}
public long b(int i) {
return this.d[i];
}
@Override
public void close() {
for (InputStream inputStream : this.c) {
com.moqi.sdk.cache.d.a(inputStream);
}
}
public String getString(int i) throws IOException {
return a.b(a(i));
}
}
private a(File file, int i, int i2, long j) {
this.a = file;
this.e = i;
this.b = new File(file, o);
this.c = new File(file, p);
this.d = new File(file, q);
this.g = i2;
this.f = j;
}
public synchronized c a(String str, long j) throws IOException {
b();
e(str);
d dVar = this.j.get(str);
CallableC2403a callableC2403a = null;
if (j != -1 && (dVar == null || dVar.e != j)) {
return null;
}
if (dVar == null) {
dVar = new d(this, str, callableC2403a);
this.j.put(str, dVar);
} else if (dVar.d != null) {
return null;
}
c cVar = new c(this, dVar, callableC2403a);
dVar.d = cVar;
this.i.write("DIRTY " + str + '\n');
this.i.flush();
return cVar;
}
public static a a(File file, int i, int i2, long j) throws IOException {
if (j <= 0) {
throw new IllegalArgumentException("maxSize <= 0");
}
if (i2 <= 0) {
throw new IllegalArgumentException("valueCount <= 0");
}
File file2 = new File(file, q);
if (file2.exists()) {
File file3 = new File(file, o);
if (file3.exists()) {
file2.delete();
} else {
a(file2, file3, false);
}
}
a aVar = new a(file, i, i2, j);
if (aVar.b.exists()) {
try {
aVar.h();
aVar.g();
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.i();
return aVar2;
}
public synchronized void a(c cVar, boolean z2) throws IOException {
d dVar = cVar.a;
if (dVar.d != cVar) {
throw new IllegalStateException();
}
if (z2 && !dVar.c) {
for (int i = 0; i < this.g; i++) {
if (!cVar.b[i]) {
cVar.a();
throw new IllegalStateException("Newly created entry didn't create value for index " + i);
}
if (!dVar.b(i).exists()) {
cVar.a();
return;
}
}
}
for (int i2 = 0; i2 < this.g; i2++) {
File b2 = dVar.b(i2);
if (!z2) {
a(b2);
} else 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.h = (this.h - j) + length;
}
}
this.k++;
dVar.d = null;
if (dVar.c || z2) {
dVar.c = true;
this.i.write("CLEAN " + dVar.a + dVar.a() + '\n');
if (z2) {
long j2 = this.l;
this.l = 1 + j2;
dVar.e = j2;
}
} else {
this.j.remove(dVar.a);
this.i.write("REMOVE " + dVar.a + '\n');
}
this.i.flush();
if (this.h > this.f || f()) {
this.m.submit(this.n);
}
}
private static void a(File file) throws IOException {
if (file.exists() && !file.delete()) {
throw new IOException();
}
}
private static void a(File file, File file2, boolean z2) throws IOException {
if (z2) {
a(file2);
}
if (!file.renameTo(file2)) {
throw new IOException();
}
}
public static String b(InputStream inputStream) throws IOException {
return com.moqi.sdk.cache.d.a((Reader) new InputStreamReader(inputStream, com.moqi.sdk.cache.d.b));
}
private void b() {
if (this.i == null) {
throw new IllegalStateException("cache is closed");
}
}
private void c(String str) throws IOException {
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(y)) {
this.j.remove(substring);
return;
}
} else {
substring = str.substring(i, indexOf2);
}
d dVar = this.j.get(substring);
CallableC2403a callableC2403a = null;
if (dVar == null) {
dVar = new d(this, substring, callableC2403a);
this.j.put(substring, dVar);
}
if (indexOf2 != -1 && indexOf == 5 && str.startsWith(w)) {
String[] split = str.substring(indexOf2 + 1).split(" ");
dVar.c = true;
dVar.d = null;
dVar.b(split);
return;
}
if (indexOf2 == -1 && indexOf == 5 && str.startsWith(x)) {
dVar.d = new c(this, dVar, callableC2403a);
return;
}
if (indexOf2 == -1 && indexOf == 4 && str.startsWith(z)) {
return;
}
throw new IOException("unexpected journal line: " + str);
}
private void e(String str) {
if (v.matcher(str).matches()) {
return;
}
throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,120}: \"" + str + "\"");
}
public boolean f() {
int i = this.k;
return i >= 2000 && i >= this.j.size();
}
private void g() throws IOException {
a(this.c);
Iterator<d> it = this.j.values().iterator();
while (it.hasNext()) {
d next = it.next();
int i = 0;
if (next.d == null) {
while (i < this.g) {
this.h += next.b[i];
i++;
}
} else {
next.d = null;
while (i < this.g) {
a(next.a(i));
a(next.b(i));
i++;
}
it.remove();
}
}
}
private void h() throws IOException {
com.moqi.sdk.cache.c cVar = new com.moqi.sdk.cache.c(new FileInputStream(this.b), com.moqi.sdk.cache.d.a);
try {
String c2 = cVar.c();
String c3 = cVar.c();
String c4 = cVar.c();
String c5 = cVar.c();
String c6 = cVar.c();
if (!r.equals(c2) || !"1".equals(c3) || !Integer.toString(this.e).equals(c4) || !Integer.toString(this.g).equals(c5) || !"".equals(c6)) {
throw new IOException("unexpected journal header: [" + c2 + ", " + c3 + ", " + c5 + ", " + c6 + "]");
}
int i = 0;
while (true) {
try {
c(cVar.c());
i++;
} catch (EOFException unused) {
this.k = i - this.j.size();
if (cVar.b()) {
i();
} else {
this.i = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.b, true), com.moqi.sdk.cache.d.a));
}
com.moqi.sdk.cache.d.a(cVar);
return;
}
}
} catch (Throwable th) {
com.moqi.sdk.cache.d.a(cVar);
throw th;
}
}
public synchronized void i() throws IOException {
StringBuilder sb;
Writer writer = this.i;
if (writer != null) {
writer.close();
}
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.c), com.moqi.sdk.cache.d.a));
try {
bufferedWriter.write(r);
bufferedWriter.write("\n");
bufferedWriter.write("1");
bufferedWriter.write("\n");
bufferedWriter.write(Integer.toString(this.e));
bufferedWriter.write("\n");
bufferedWriter.write(Integer.toString(this.g));
bufferedWriter.write("\n");
bufferedWriter.write("\n");
for (d dVar : this.j.values()) {
if (dVar.d != null) {
sb = new StringBuilder();
sb.append("DIRTY ");
sb.append(dVar.a);
sb.append('\n');
} else {
sb = new StringBuilder();
sb.append("CLEAN ");
sb.append(dVar.a);
sb.append(dVar.a());
sb.append('\n');
}
bufferedWriter.write(sb.toString());
}
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), com.moqi.sdk.cache.d.a));
} catch (Throwable th) {
bufferedWriter.close();
throw th;
}
}
public void j() throws IOException {
while (this.h > this.f) {
d(this.j.entrySet().iterator().next().getKey());
}
}
public c a(String str) throws IOException {
return a(str, -1L);
}
public synchronized void a(long j) {
this.f = j;
this.m.submit(this.n);
}
public synchronized e b(String str) throws IOException {
InputStream inputStream;
b();
e(str);
d dVar = this.j.get(str);
if (dVar == null) {
return null;
}
if (!dVar.c) {
return null;
}
InputStream[] inputStreamArr = new InputStream[this.g];
for (int i = 0; i < this.g; i++) {
try {
inputStreamArr[i] = new FileInputStream(dVar.a(i));
} catch (FileNotFoundException unused) {
for (int i2 = 0; i2 < this.g && (inputStream = inputStreamArr[i2]) != null; i2++) {
com.moqi.sdk.cache.d.a(inputStream);
}
return null;
}
}
this.k++;
this.i.append((CharSequence) ("READ " + str + '\n'));
if (f()) {
this.m.submit(this.n);
}
return new e(this, str, dVar.e, inputStreamArr, dVar.b, null);
}
public void c() throws IOException {
close();
com.moqi.sdk.cache.d.a(this.a);
}
@Override
public synchronized void close() throws IOException {
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();
}
}
j();
this.i.close();
this.i = null;
}
public File d() {
return this.a;
}
public synchronized boolean d(String str) throws IOException {
b();
e(str);
d dVar = this.j.get(str);
if (dVar != null && dVar.d == null) {
for (int i = 0; i < this.g; i++) {
File a = dVar.a(i);
if (a.exists() && !a.delete()) {
throw new IOException("failed to delete " + a);
}
this.h -= dVar.b[i];
dVar.b[i] = 0;
}
this.k++;
this.i.append((CharSequence) ("REMOVE " + str + '\n'));
this.j.remove(str);
if (f()) {
this.m.submit(this.n);
}
return true;
}
return false;
}
public synchronized long e() {
return this.f;
}
public synchronized void flush() throws IOException {
b();
j();
this.i.flush();
}
public synchronized boolean isClosed() {
return this.i == null;
}
public synchronized long size() {
return this.h;
}
}