package com.google.android.play.core.assetpacks; import java.io.File; import java.io.FileInputStream; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; /* loaded from: classes2.dex */ abstract class d3 { /* renamed from: a, reason: collision with root package name */ private static final Pattern f4827a = Pattern.compile("[0-9]+-(NAM|LFH)\\.dat"); static List a(File file, File file2) { File[] fileArr; ArrayList arrayList = new ArrayList(); File[] listFiles = file2.listFiles(new FilenameFilter() { // from class: com.google.android.play.core.assetpacks.c3 @Override // java.io.FilenameFilter public final boolean accept(File file3, String str) { boolean matches; matches = d3.f4827a.matcher(str).matches(); return matches; } }); if (listFiles != null) { File[] fileArr2 = new File[listFiles.length]; int i10 = 0; while (true) { int length = listFiles.length; if (i10 >= length) { fileArr = fileArr2; break; } File file3 = listFiles[i10]; int parseInt = Integer.parseInt(file3.getName().split("-")[0]); if (parseInt > length || fileArr2[parseInt] != null) { break; } fileArr2[parseInt] = file3; i10++; } throw new d1("Metadata folder ordering corrupt."); } fileArr = new File[0]; for (File file4 : fileArr) { arrayList.add(file4); if (file4.getName().contains("LFH")) { FileInputStream fileInputStream = new FileInputStream(file4); try { h3 z10 = new q0(fileInputStream).z(); if (z10.c() == null) { throw new d1("Metadata files corrupt. Could not read local file header."); } File file5 = new File(file, z10.c()); if (!file5.exists()) { throw new d1(String.format("Missing asset file %s during slice reconstruction.", file5.getCanonicalPath())); } arrayList.add(file5); fileInputStream.close(); } catch (Throwable th) { try { fileInputStream.close(); } catch (Throwable th2) { th.addSuppressed(th2); } throw th; } } } return arrayList; } }