package okhttp3.repackaged.internal.io; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import o.C15145giV; import o.giX; import o.giZ; /* loaded from: classes6.dex */ public interface FileSystem { public static final FileSystem SYSTEM = new FileSystem() { // from class: okhttp3.repackaged.internal.io.FileSystem.1 @Override // okhttp3.repackaged.internal.io.FileSystem public final giZ source(File file) throws FileNotFoundException { return C15145giV.d(file); } @Override // okhttp3.repackaged.internal.io.FileSystem public final giX sink(File file) throws FileNotFoundException { try { return C15145giV.e(file); } catch (FileNotFoundException unused) { file.getParentFile().mkdirs(); return C15145giV.e(file); } } @Override // okhttp3.repackaged.internal.io.FileSystem public final giX appendingSink(File file) throws FileNotFoundException { try { return C15145giV.b(file); } catch (FileNotFoundException unused) { file.getParentFile().mkdirs(); return C15145giV.b(file); } } @Override // okhttp3.repackaged.internal.io.FileSystem public final void delete(File file) throws IOException { if (!file.delete() && file.exists()) { throw new IOException("failed to delete ".concat(String.valueOf(file))); } } @Override // okhttp3.repackaged.internal.io.FileSystem public final boolean exists(File file) { return file.exists(); } @Override // okhttp3.repackaged.internal.io.FileSystem public final long size(File file) { return file.length(); } @Override // okhttp3.repackaged.internal.io.FileSystem public final void rename(File file, File file2) throws IOException { delete(file2); if (file.renameTo(file2)) { return; } StringBuilder sb = new StringBuilder("failed to rename "); sb.append(file); sb.append(" to "); sb.append(file2); throw new IOException(sb.toString()); } @Override // okhttp3.repackaged.internal.io.FileSystem public final void deleteContents(File file) throws IOException { File[] listFiles = file.listFiles(); if (listFiles == null) { throw new IOException("not a readable directory: ".concat(String.valueOf(file))); } for (File file2 : listFiles) { if (file2.isDirectory()) { deleteContents(file2); } if (!file2.delete()) { throw new IOException("failed to delete ".concat(String.valueOf(file2))); } } } }; giX appendingSink(File file) throws FileNotFoundException; void delete(File file) throws IOException; void deleteContents(File file) throws IOException; boolean exists(File file); void rename(File file, File file2) throws IOException; giX sink(File file) throws FileNotFoundException; long size(File file); giZ source(File file) throws FileNotFoundException; }