package com.igaworks.ssp.common.o; import android.content.Context; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /* loaded from: classes2.dex */ public class f { /* renamed from: a, reason: collision with root package name */ private static int f6819a = 1; /* renamed from: b, reason: collision with root package name */ private static String f6820b = "tempFile-ssp-"; /* renamed from: c, reason: collision with root package name */ private static String f6821c = ".html"; public enum a { MODE_PRIVATE, MODE_APPEND } public static synchronized String a() { String str; synchronized (f.class) { try { str = f6820b + f6819a + f6821c; int i10 = f6819a + 1; f6819a = i10; if (i10 > 6) { f6819a = 1; } } catch (Exception unused) { str = "tempFile-ssp-0.html"; } } return str; } public static void a(Context context) { StringBuilder sb; String str; Thread currentThread; StringBuilder sb2; if (context == null) { return; } for (int i10 = -1; i10 <= 4; i10++) { if (i10 == -1) { try { sb = new StringBuilder(); sb.append(context.getFilesDir().getPath()); str = "/tempFile-ssp-o.html"; } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); return; } } else { sb = new StringBuilder(); sb.append(context.getFilesDir().getPath()); sb.append("/"); sb.append(f6820b); sb.append(i10); str = f6821c; } sb.append(str); String sb3 = sb.toString(); File file = new File(sb3); if (file.exists()) { if (file.delete()) { currentThread = Thread.currentThread(); sb2 = new StringBuilder(); sb2.append("destroyInternalFiles Deleted : "); sb2.append(sb3); } else { currentThread = Thread.currentThread(); sb2 = new StringBuilder(); sb2.append("destroyInternalFiles not Deleted : "); sb2.append(sb3); } com.igaworks.ssp.common.o.m.a.a(currentThread, sb2.toString()); } } } public static void a(Context context, String str, byte[] bArr, a aVar) { a aVar2 = a.MODE_APPEND; if (aVar == aVar2 || aVar == a.MODE_PRIVATE) { FileOutputStream fileOutputStream = null; try { try { fileOutputStream = aVar == aVar2 ? context.openFileOutput(str, 32768) : context.openFileOutput(str, 0); fileOutputStream.write(bArr); } catch (Exception e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); if (fileOutputStream == null) { return; } } try { fileOutputStream.close(); } catch (IOException unused) { } } catch (Throwable th) { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException unused2) { } } throw th; } } } public static boolean a(String str) { try { try { new FileInputStream(new File(str)).close(); } catch (Exception unused) { } return true; } catch (FileNotFoundException e10) { com.igaworks.ssp.common.o.m.a.a(Thread.currentThread(), e10); return false; } } }