content: package okhttp3.internal.io;
  
  import androidx.constraintlayout.core.motion.utils.TypedValues;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import kotlin.Metadata;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import okio.Okio;
  import okio.Sink;
  import okio.Source;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bf\u0018\u0000 \u00142\u00020\u0001:\u0001\u0014J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0010\u0010\u0006\u001a\u00020\u00072\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0010\u0010\b\u001a\u00020\u00072\u0006\u0010\t\u001a\u00020\u0005H&J\u0010\u0010\n\u001a\u00020\u000b2\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0018\u0010\f\u001a\u00020\u00072\u0006\u0010\r\u001a\u00020\u00052\u0006\u0010\u000e\u001a\u00020\u0005H&J\u0010\u0010\u000f\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0010\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0004\u001a\u00020\u0005H&J\u0010\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0004\u001a\u00020\u0005H&¨\u0006\u0015"}, d2 = {"Lokhttp3/internal/io/FileSystem;", "", "appendingSink", "Lokio/Sink;", "file", "Ljava/io/File;", "delete", "", "deleteContents", "directory", "exists", "", "rename", "from", "to", "sink", "size", "", "source", "Lokio/Source;", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: FileSystem.kt */
  public interface FileSystem {
      public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
      public static final FileSystem SYSTEM = new Companion.SystemFileSystem();
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0003\u0018\u00002\u00020\u0001:\u0001\u0005B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0016\u0010\u0003\u001a\u00020\u00048\u0006X\u0004ø\u0001\u0000¢\u0006\u0002\n\u0000¨\u0006\u0001\u0002\u0007\n\u0005\bF0\u0001¨\u0006\u0006"}, d2 = {"Lokhttp3/internal/io/FileSystem$Companion;", "", "()V", "SYSTEM", "Lokhttp3/internal/io/FileSystem;", "SystemFileSystem", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: FileSystem.kt */
      public static final class Companion {
          static final /* synthetic */ Companion $$INSTANCE = null;
  
          @Metadata(bv = {1, 0, 3}, d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\u0007\u001a\u00020\b2\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\t\u001a\u00020\b2\u0006\u0010\n\u001a\u00020\u0006H\u0016J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0018\u0010\r\u001a\u00020\b2\u0006\u0010\u000e\u001a\u00020\u00062\u0006\u0010\u000f\u001a\u00020\u0006H\u0016J\u0010\u0010\u0010\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\u0010\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0005\u001a\u00020\u0006H\u0016J\b\u0010\u0015\u001a\u00020\u0016H\u0016¨\u0006\u0017"}, d2 = {"Lokhttp3/internal/io/FileSystem$Companion$SystemFileSystem;", "Lokhttp3/internal/io/FileSystem;", "()V", "appendingSink", "Lokio/Sink;", "file", "Ljava/io/File;", "delete", "", "deleteContents", "directory", "exists", "", "rename", "from", "to", "sink", "size", "", "source", "Lokio/Source;", "toString", "", "okhttp"}, k = 1, mv = {1, 4, 0})
          /* compiled from: FileSystem.kt */
          private static final class SystemFileSystem implements FileSystem {
              public Sink appendingSink(File file) throws FileNotFoundException {
                  Intrinsics.checkNotNullParameter(file, "file");
                  try {
                      return Okio.appendingSink(file);
                  } catch (FileNotFoundException e) {
                      file.getParentFile().mkdirs();
                      return Okio.appendingSink(file);
                  }
              }
  
              public void delete(File file) throws IOException {
                  Intrinsics.checkNotNullParameter(file, "file");
                  if (!file.delete() && file.exists()) {
                      throw new IOException("failed to delete " + file);
                  }
              }
  
              public void deleteContents(File directory) throws IOException {
                  Intrinsics.checkNotNullParameter(directory, "directory");
                  File[] listFiles = directory.listFiles();
                  if (listFiles != null) {
                      int length = listFiles.length;
                      int i = 0;
                      while (i < length) {
                          File file = listFiles[i];
                          Intrinsics.checkNotNullExpressionValue(file, "file");
                          if (file.isDirectory()) {
                              deleteContents(file);
                          }
                          if (file.delete()) {
                              i++;
                          } else {
                              throw new IOException("failed to delete " + file);
                          }
                      }
                      return;
                  }
                  throw new IOException("not a readable directory: " + directory);
              }
  
              public boolean exists(File file) {
                  Intrinsics.checkNotNullParameter(file, "file");
                  return file.exists();
              }
  
              public void rename(File from, File to) throws IOException {
                  Intrinsics.checkNotNullParameter(from, TypedValues.TransitionType.S_FROM);
                  Intrinsics.checkNotNullParameter(to, TypedValues.TransitionType.S_TO);
                  delete(to);
                  if (!from.renameTo(to)) {
                      throw new IOException("failed to rename " + from + " to " + to);
                  }
              }
  
              public Sink sink(File file) throws FileNotFoundException {
                  Intrinsics.checkNotNullParameter(file, "file");
                  try {
                      return Okio__JvmOkioKt.sink$default(file, false, 1, (Object) null);
                  } catch (FileNotFoundException e) {
                      file.getParentFile().mkdirs();
                      return Okio__JvmOkioKt.sink$default(file, false, 1, (Object) null);
                  }
              }
  
              public long size(File file) {
                  Intrinsics.checkNotNullParameter(file, "file");
                  return file.length();
              }
  
              public Source source(File file) throws FileNotFoundException {
                  Intrinsics.checkNotNullParameter(file, "file");
                  return Okio.source(file);
              }
  
              public String toString() {
                  return "FileSystem.SYSTEM";
              }
          }
  
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
      }
  
      Sink 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;
  
      Sink sink(File file) throws FileNotFoundException;
  
      long size(File file);
  
      Source source(File file) throws FileNotFoundException;
  }
  