package com.mbridge.msdk.foundation.same.b; import com.mbridge.msdk.foundation.tools.af; import com.mbridge.msdk.foundation.tools.ai; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /* loaded from: classes4.dex */ public final class e { private static volatile e a; private final b b; private final ArrayList c = new ArrayList<>(); private e(b bVar) { this.b = bVar; } public static String a(c cVar) { File b = b(cVar); if (b != null) { return b.getAbsolutePath(); } return null; } public static File b(c cVar) { try { if (a() == null || a().c == null || a().c.isEmpty()) { return null; } Iterator it = a().c.iterator(); while (it.hasNext()) { a next = it.next(); if (next.b.equals(cVar)) { return next.a; } } return null; } catch (Throwable th) { af.b("MBridgeDirManager", th.getMessage(), th); return null; } } public static synchronized e a() { e eVar; synchronized (e.class) { try { if (a == null && com.mbridge.msdk.foundation.controller.c.m().c() != null) { ai.a(com.mbridge.msdk.foundation.controller.c.m().c()); } eVar = a; } catch (Throwable th) { throw th; } } return eVar; } public static synchronized void a(b bVar) { synchronized (e.class) { if (a == null) { a = new e(bVar); } } } public final boolean b() { return a(this.b.b()); } private boolean a(com.mbridge.msdk.foundation.same.b.a aVar) { String str; com.mbridge.msdk.foundation.same.b.a c = aVar.c(); if (c == null) { str = aVar.b(); } else { File b = b(c.d()); if (b == null) { return false; } str = b.getAbsolutePath() + File.separator + aVar.b(); } File file = new File(str); if (!file.exists() && !file.mkdirs()) { return false; } this.c.add(new a(aVar.d(), file)); List a2 = aVar.a(); if (a2 == null) { return true; } Iterator it = a2.iterator(); while (it.hasNext()) { if (!a(it.next())) { return false; } } return true; } public static final class a { public File a; public c b; public a(c cVar, File file) { this.b = cVar; this.a = file; } } }