jimu-decompiled/sources/androidx/multidex/ZipUtil.java
2025-05-13 19:24:51 +02:00

72 lines
2.6 KiB
Java

package androidx.multidex;
import android.support.v4.media.session.PlaybackStateCompat;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.zip.CRC32;
import java.util.zip.ZipException;
/* loaded from: classes.dex */
final class ZipUtil {
static class CentralDirectory {
long a;
long b;
CentralDirectory() {
}
}
static long a(File file) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
try {
return a(randomAccessFile, a(randomAccessFile));
} finally {
randomAccessFile.close();
}
}
static CentralDirectory a(RandomAccessFile randomAccessFile) throws IOException, ZipException {
long length = randomAccessFile.length() - 22;
if (length >= 0) {
long j = length - PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH;
long j2 = j >= 0 ? j : 0L;
int reverseBytes = Integer.reverseBytes(101010256);
do {
randomAccessFile.seek(length);
if (randomAccessFile.readInt() == reverseBytes) {
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
CentralDirectory centralDirectory = new CentralDirectory();
centralDirectory.b = Integer.reverseBytes(randomAccessFile.readInt()) & 4294967295L;
centralDirectory.a = Integer.reverseBytes(randomAccessFile.readInt()) & 4294967295L;
return centralDirectory;
}
length--;
} while (length >= j2);
throw new ZipException("End Of Central Directory signature not found");
}
throw new ZipException("File too short to be a zip file: " + randomAccessFile.length());
}
static long a(RandomAccessFile randomAccessFile, CentralDirectory centralDirectory) throws IOException {
CRC32 crc32 = new CRC32();
long j = centralDirectory.b;
randomAccessFile.seek(centralDirectory.a);
byte[] bArr = new byte[16384];
int read = randomAccessFile.read(bArr, 0, (int) Math.min(PlaybackStateCompat.ACTION_PREPARE, j));
while (read != -1) {
crc32.update(bArr, 0, read);
j -= read;
if (j == 0) {
break;
}
read = randomAccessFile.read(bArr, 0, (int) Math.min(PlaybackStateCompat.ACTION_PREPARE, j));
}
return crc32.getValue();
}
}