Files
rr3-apk/decompiled/sources/androidx/multidex/ZipUtil.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

73 lines
2.8 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 {
private static final int BUFFER_SIZE = 16384;
private static final int ENDHDR = 22;
private static final int ENDSIG = 101010256;
public static class CentralDirectory {
long offset;
long size;
}
public static long getZipCrc(File file) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
try {
return computeCrcOfCentralDir(randomAccessFile, findCentralDirectory(randomAccessFile));
} finally {
randomAccessFile.close();
}
}
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 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(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();
}
}