alexandroid/decompiled/jadx/sources/androidx/multidex/ZipUtil.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

73 lines
2.8 KiB
Java

package androidx.multidex;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.zip.CRC32;
import java.util.zip.ZipException;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes14.dex */
final class ZipUtil {
private static final int BUFFER_SIZE = 16384;
private static final int ENDHDR = 22;
private static final int ENDSIG = 101010256;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static class CentralDirectory {
long offset;
long size;
}
public static long computeCrcOfCentralDir(RandomAccessFile randomAccessFile, CentralDirectory centralDirectory) throws IOException {
CRC32 crc32 = new CRC32();
long j = centralDirectory.size;
randomAccessFile.seek(centralDirectory.offset);
byte[] bArr = new byte[16384];
int read = randomAccessFile.read(bArr, 0, (int) Math.min(16384L, j));
while (read != -1) {
crc32.update(bArr, 0, read);
j -= read;
if (j == 0) {
break;
}
read = randomAccessFile.read(bArr, 0, (int) Math.min(16384L, j));
}
return crc32.getValue();
}
public static CentralDirectory findCentralDirectory(RandomAccessFile randomAccessFile) throws IOException, ZipException {
long length = randomAccessFile.length();
long j = length - 22;
if (j < 0) {
throw new ZipException("File too short to be a zip file: " + randomAccessFile.length());
}
long j2 = length - 65558;
long j3 = j2 >= 0 ? j2 : 0L;
int reverseBytes = Integer.reverseBytes(ENDSIG);
do {
randomAccessFile.seek(j);
if (randomAccessFile.readInt() == reverseBytes) {
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
randomAccessFile.skipBytes(2);
CentralDirectory centralDirectory = new CentralDirectory();
centralDirectory.size = Integer.reverseBytes(randomAccessFile.readInt()) & 4294967295L;
centralDirectory.offset = Integer.reverseBytes(randomAccessFile.readInt()) & 4294967295L;
return centralDirectory;
}
j--;
} while (j >= j3);
throw new ZipException("End Of Central Directory signature not found");
}
public static long getZipCrc(File file) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
try {
return computeCrcOfCentralDir(randomAccessFile, findCentralDirectory(randomAccessFile));
} finally {
randomAccessFile.close();
}
}
}